Tagged Questions
Java (not to be confused with JavaScript) is a class-based, object-oriented, strongly typed, reflective language and run-time environment (JRE). Java programs are compiled to bytecode and run in a virtual machine (JVM) enabling a "write once, run anywhere" (WORA) methodology.
1
vote
1answer
23 views
Caching all the prepared statements in thread safe way
I have a below Singleton class where in my getStatement method, I populate a CHM by doing if check.
...
-3
votes
0answers
18 views
Triangle Classification [on hold]
I require help to design a program where a user enters 3 sides of a triangle. The 3 sides are used to determine the classification of triangle among isosceles, scalene and equilateral. Then the sides ...
3
votes
3answers
37 views
Generating 50 Random Shapes
I am a beginner Java programmer. I have just finished up an assignment and would appreciate some advice and/or constructive criticism on my program. For context, I have the assignment details, ...
4
votes
3answers
220 views
Custom exception for string that is too long
This is my first time working with Java exceptions. I have made a program that works to specifications, but I am wondering if there is anything I've done which is unconventional or not recommended. ...
1
vote
1answer
20 views
Tarjan's strongly connected components algorithm
Can anyone suggest to me how I can make this "nicer"? If you can see any glaring details that I could change to speed things up too, that would be great -- though it's not priority.
...
-4
votes
0answers
26 views
randon mulitplication [on hold]
Your little sister asks you to help her with her multiplication and you decide to write a Java application that tests her skills. The program will let her input a starting number, such as 5. It will ...
3
votes
4answers
55 views
Check for Palindrome string in Java
I was wondering if you can give me advice on this solution to assess if an user input string is a palindrome or not.
How can I optimize this solution?
...
3
votes
1answer
37 views
Snakes and Ladders using a magic die
This is a problem from here where you're given a magic die, and the objective is to find the minimum number of dice throws (hops) to go from the start point to the end of the board, and win the game.
...
0
votes
0answers
10 views
Java out of bounds and infinite loop error on Java dijkstra's code? [on hold]
I am not sure why but I am stuck in an infinite loop somewhere in this code and there seems to be some edge case/out of bounds error that I do not see.
Could someone please review my code for errors. ...
3
votes
1answer
48 views
Simple bank account
I believe it is very much possible to make this code more efficient, possibly adding interfaces, inheritance or possibly divide the main class into more classes. I will improve some of the code such ...
4
votes
2answers
56 views
Replacing consecutive equal elements in a list with a new element
In the code below I will replace all consecutive equal elements in a list with a new element. In this case I have chosen the new element to simply be the concatenation of all the equal elements, but I ...
-4
votes
0answers
12 views
About the Nodes ( states ) in BFS algorithm [on hold]
i am confused about the BFS algorithm ,
i know how can i do the BFS in graph search , for example , a-b-c-d and so on
if i have a maze , for example to the maze :
...
0
votes
1answer
66 views
0
votes
0answers
18 views
Simple API testing framework for testing of SOAP xml requests
I have a need to try to automate the testing of a large Web Service with an XML API interface. The framework takes the form of a Mavenised Java project.
The usual maxims apply: must be highly ...
4
votes
0answers
60 views
Test and implementation of a reorderable data structure that stores number of users (classifiable as per gender, country, etc.) of an Application
I have implemented a data structure that allows storage of number of users of a hypothetical application in a tree-like data structure in nodes as per their classification based on categories such as ...
3
votes
2answers
63 views
Singleton Pattern + unavoidable Public Constructor
We have an object that needs to be converted to a different type before storing it in database. For that purpose, the library provides an annotation over the field that specifies the appropriate class[...
1
vote
1answer
43 views
Hashing 2 strings to an int and adding to HashMap
I am trying to use an algorithm similar to the Apriori algorithm for discovering frequent itemsets. This program hashes 2 strings to an int and maps them in the HashMap. I'm not concerned with how ...
-1
votes
0answers
25 views
10
votes
0answers
72 views
Brainfuck to x86 Assembly Compiler
After my Brainfuck Interpreter written in x86 Assembly I decided that it was time to get to the next step, writing a Brainfuck Compiler in Java that generates x86 Assembly and compiles that to an ...
0
votes
0answers
30 views
Extract strings from Deterministic finite automaton
I have created a class which one can build a Deterministic Finite Automaton, with different states - including a start state and one or several accepting states. Also, every transitions has at least ...
0
votes
1answer
53 views
Line count of each file in a given directory efficiently using akka
This is my first program in akka so I wanted to know if the program is efficient and is using the advantages of actor model.
The program's purpose is to scan a given directory for any files and print ...
3
votes
2answers
51 views
Enforce execution order with collections of CompleteableFuture's
I receive a message that contains a collection of items that need to be processed.
Processing each item involves sequential calls to various services.
The services return a ...
2
votes
1answer
62 views
Refactored game of Snake
A week ago I requested a review of my code for a game of Snake.
First game of Snake
I made some changes based on your answers and now I want to show you present code. Something else to modify here?
...
0
votes
0answers
13 views
Program to ask for three integers and report the minimum [on hold]
I'm trying to break this code up into multiple methods and I was successful with the first bit but the other two I can't seem to figure out.
With the second method I was trying to make it so it would ...
4
votes
3answers
114 views
Swing Temperature Converter
I made a simple temperature converter to serve as an introduction to swing. I used Eclipse WindowBuilder and did not attempt to make the components more modular. I'm curious as to how you guys would ...
4
votes
3answers
114 views
Adventure text game
I'm making a text based java game to help me learn java. I would like to know if I am doing things ok and if there is a better way to do the things I'm doing thanks. I have two separate files.
...
3
votes
1answer
48 views
Hackerrank Sparse Arrays Solution in Java
I've just solved this problem and I hope you guys give me any feedbacks to make my code be better. Thanks a lot!
Problem: There are strings. Each string's length is no more than characters. There ...
3
votes
2answers
47 views
Compress an array of strings in Android
I'm compressing an array of strings in an Android app. Is there something you would suggest?
...
4
votes
3answers
302 views
Reading properties from file during standalone application startup
I've a standalone Java application, which basically starts and manages two socket servers. I'd like to configure server ports in a .properties file using the ...
-3
votes
0answers
32 views
8
votes
1answer
824 views
Guessing the JDK home directory
My project is using a specific version of JDK which is jdk-6 and the default JDK_HOME path will vary from distribution to distribution, so I wrote a script to guess it. Is there any way to do this ...
2
votes
1answer
82 views
+50
Android recycler view adapter filter
I am trying to optimize the filter method for RecyclerView Adapter in Android. The list is used as an ArrayList. I have seen ...
1
vote
1answer
82 views
Simple magic 8 ball program
I would just like some input on how I may improve my code(in terms of content not formatting) without changing the output. It's just a simple magic 8 ball program using dialog boxes.
...
2
votes
1answer
63 views
Simple Snake clone in Java
I made a Snake clone for a programming class. I wanted some feedback regarding coding style and will appreciate any other opinions concerning my code.
...
4
votes
1answer
68 views
6502 CPU emulator in Java
I want to make sure I won't have to go back and redo large chunks of code. I have each opcode as a value in an enum that implements Runnable. Is there a more ...
2
votes
3answers
58 views
Returning distinct characters in combined Strings
I am trying to return distinct characters from the combination of 2 Strings. The following is my solution which seems to work based on my tests.
Is there a more ...
0
votes
0answers
21 views
Responsibility to Validate Move in chess game? [closed]
I came across couple of software LLD to design chess game. I have a specific question where behavior to validateMove of pieces should lie ? Should it be part of piece class or validator class ?
Per ...
7
votes
5answers
1k views
FizzBuzz Implementation in Java
Fairly new to learning interview questions and I saw this one and gave it a shot. I would very much appreciate some constructive criticism of how I went about it and what you would tell me if you were ...
0
votes
0answers
10 views
Monty Hall Java Project - stuck in a while loop that scans user response [closed]
I just learned how to code a few months ago so pardon my style, I know there are many more efficient ways to do it but please understand that I am still expanding my skill set.
In class we were asked ...
2
votes
1answer
40 views
Finding an arbitrary word in a string of words given an offset
Background
Given a string (s) and an offset into that string (offset), find the whole word that can be found at the given ...
-1
votes
0answers
16 views
My web application in Spring [closed]
I am learning Spring and I wanted to show you what I'v done so far.
In this project I am using: Spring, Twitter Bootstrap, Apache Tiles, Hibernate.
Code:
https://github.com/siejajedrzej/quick
...
0
votes
0answers
9 views
3
votes
0answers
27 views
PopupMenu implementation that hacks inflating a @MenuRes
Summary
Usage will ask for a Context and a @MenuRes and then use the ...
-1
votes
4answers
62 views
Unique values of an array
I'm curious if there is another way to code this. Could it be done with a while loop for instance?
...
7
votes
2answers
378 views
Huffman compressor in Java
I have this Java program that can en-/decode files, both text and binary. What comes to critique I want to hear anything regarding these points:
Performance,
Modularity,
Coding conventions,
Naming ...
6
votes
3answers
97 views
Slot Machine Simulator with JAVA
I'm studying alone, so I don't know if I'm writing efficiently. Could this SLOT MACHINE SIMULATOR code be improved? How?
...
0
votes
0answers
22 views
4
votes
2answers
56 views
REST API integration test
We have a (Spring) REST API that I was tasked to write integration tests for. I wrote various ways to test our REST API and then just decided to make 1 integration test class that processes all JSON ...
0
votes
1answer
15 views
Sort the input file text by most frequent and alphabetically [closed]
The input file is a long .txt file that is indicated by a path. The program should be able to find the most frequent words in the file. As well as the output should be sorted, if 2 words appear the ...
3
votes
2answers
54 views
Tiling an nxn grid with L-shaped Trominoes
This is some code I wrote in order to see if it was possible to tile a 9x9 grid using trominoes that are shaped like this:
_
| |_
|___|
(They can be rotated.)
One issue I had while ...