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 byte-code and run in a virtual machine (JVM) enabling a "write once, run anywhere" (WORA) methodology.
8
votes
3answers
167 views
String related problem from CodingBat
I was trying this problem and I was wondering if there is a way to check for the edge cases inside the for-loop.
The problem statement:
We'll say that a lowercase 'g' in a string is "happy" if ...
2
votes
2answers
55 views
4
votes
2answers
73 views
Simple Hangman game
It randomly gets a word from an array of Strings. It prints out a '_' char for every letter of the word, displays the ones you ...
10
votes
5answers
693 views
Simple Console Calculator
This is my Java 8 code for a console calculator. I just want to know if it can be improved in any way.
...
2
votes
2answers
44 views
Job execution on records supplied by database
I have a requirement to check all records in a table which is big (Around 1.5-2 million records). What I am doing is very simple, just get all the records and loop through one by one, and do things. I ...
4
votes
1answer
34 views
Hackerrank regex solution
I solved the following problem on Hackerrank.
The challenge is to:
Parse HTML input and display the tags and attributes in lexicographically ascending order.
This is the input format:
...
-3
votes
0answers
22 views
15
votes
2answers
1k views
Please Save My Name
I wanted to create a save game system for my city building game that did not require the player to input a name for the city. It was also important to allow infinite save games, so I could not just ...
2
votes
1answer
29 views
Visualization of regex analysis
As I started to learn about regular expressions, and as part of bigger project, I wrote a regex analyzer, which:
takes the PROPER regular expression,
takes the String already MATCHED by this regex,
...
4
votes
3answers
60 views
Shape Calculator in Java
This is my first time putting up a completed program onto the web and I was hoping to get some feedback on these areas:
Commenting (Too much, not enough or do I need to simplify anything)
Structure ...
1
vote
2answers
111 views
Array with enumerated elements
Java program uses the following construction: (provided mainly for context)
...
-5
votes
0answers
22 views
2
votes
1answer
44 views
Bottom up mergesort in Java
I have this iterative mergesort (a.k.a. bottom-up mergesort).
BottomUpMergesort.java:
...
-6
votes
0answers
32 views
Function to print a url [on hold]
I want to create a function that prints a url in Java. I was wonder if my code can be improved:
...
4
votes
2answers
57 views
Obstacle-avoiding AI
I have made a game in Java that involves two players to fight each other with spaceships. For one player mode, I have programmed a simple AI to avoid allies and asteroids and go straight towards the ...
5
votes
6answers
1k views
Adventure game player using public fields instead of getters and setters
I was writing class Player with private fields and getters and setters. But the number of methods started to grow, I used lists ...
6
votes
3answers
229 views
Geometry Calculations - Cube, Sphere, and Tetrahedron
This is the first code I've written. It's for an intro to Java course. Could you look over it and let me know of things I could improve before handing it in?
For reference, I've also provided what ...
4
votes
1answer
39 views
XML parsing in Java using SAX parser
I have started learning XML parsing in Java (currently reading Java & XML by Brett McLaughlin). Here is my first program to parse XML using SAX parser. Please review the code and let me know if ...
6
votes
1answer
35 views
JMS consumer for message retrieval and listening
I created a standalone Java application that acts as a consumer that retrieves/listens for messages inside an ActiveMQ queue. Planning to run two instances of these on different machines for high ...
6
votes
0answers
51 views
+100
Ultimatoe — 1. GUI and general game interfaces
For the community challenge, I wrote ultimatoe. For me, the most interesting part is clearly the AI, but what I did so far is just a stupid Monte Carlo tree search, which isn't ready for a review yet ...
-1
votes
0answers
27 views
Generic interface and generic classes [on hold]
given a interface defined as
public interface CanBeCompared<E> {
int compare(E x);
}
I was writing a generic class when I realised that if I wanted it ...
2
votes
1answer
46 views
Moving DTOs between server/client
I am developing a server for a web-client. Basically it's just a simple CMS to modify some data. My problem is that I never had a project like this where I have to take care about the server and the ...
0
votes
0answers
31 views
Generate the combinations [duplicate]
I must write a program that given the elements in a list , generates all combinations of these elements .
For example, if I [A, B , C ] , the possible combinations are [ A] , [B ] , [ C ] , [A, B ] . ...
-2
votes
2answers
60 views
Algorithm of combinations (problem with time and space)
My algorithm generates combinations of elements. For example, having [A, B, C ] creates the following combinations [ A ], [ B ], [ C ], [ AB ], [ AC ], [ B, C ], [ ABC ].
Unfortunately for items too ...
2
votes
1answer
42 views
Graph, and a search that visits each edge exactly once in each direction
My assignment was to write a method that is capable of visiting each edge in a graph in each direction exactly once.
With it, I included a basic Graph class to test it with.
What I'd like a review ...
6
votes
3answers
214 views
Sum pairs of numbers in array
This code takes a list of ints and sums their pairs, storing the summed pairs in an array sumPairs, then returning that array. If the supplied array ...
9
votes
2answers
210 views
Removing duplicates from an unsorted Array
I have written this program to remove the duplicates from an unsorted array. Please review and give me your input on how I can improve it a little more.
...
5
votes
2answers
188 views
Simple Tic Tac Toe game
I'm just starting to learn Java and I have written this simple Tic Tac Toe game. Please review it and give me some feedback, advice, guidance etc.
Main method:
...
1
vote
2answers
102 views
JavaFX Tic-Tac-Toe Game
I programmed a Tic Tac Toe game using JavaFX, and I'm looking for a code review of it to improve my skills and practices in Java. It would highly be appreciated if you reviewers emphasize on these ...
1
vote
2answers
147 views
Sorting an Integer array
The program sorts the array from lowest to highest and outputs the index of the searched value:
...
1
vote
1answer
29 views
Fast Event Manager
I've recently coded an event manager with performance as the main factor. I'd like to know what you think of it and what could be made better.
...
3
votes
5answers
183 views
Making ArrayList.containsAll run faster
Whenever using ArrayList, the method containsAll(collection) runs in time \$\mathcal{O}(mn)\$, where \$n\$ is the size of ...
1
vote
1answer
62 views
Sudoku verifier program
I implemented a Sudoku validation program.
Can this be optimized even further in terms of performance?
...
4
votes
2answers
40 views
Program to provide CRUD operations for a Boxers(Fighter) table in a database
I have been through a few SQLite tutorials and wrote this code on my own to reinforce the principles. The tutorials I went through varied widely in a few areas so this is what I came up with as a ...
15
votes
8answers
1k views
50 states info program
Instructions:
Write a Java program the displays the State bird and flower. You should use your IDE for this exercise. The program should prompt the user to enter a state and print both the state ...
4
votes
1answer
48 views
Remote control receiver for robot control
I have built an RC car and attached a Raspberry Pi to it - in order to control it, I wrote some Java code to listen to commands over the network and make the car move accordingly.
...
10
votes
2answers
90 views
Tic Tac Towards FX
I'm planning on taking on this community challenge. However, before my tics get tactical, I'd appreciate some feedback on he simpler implementation.
Screenshots:
Factoring in all the logic/edge ...
5
votes
1answer
77 views
Click! program in Java Swing
I've created a program where the user is, at first, presented with a window with a yellow circle (random size, random coordinates) and a Start button. Once the user presses Start, the circle, when ...
-1
votes
0answers
39 views
Need to convert a complete code of javax.xml.soap.* to webServiceTemplate
I asked following question on StackOverflow but did not receive any answer. Someone suggested me to post it here.
I am able to send requests to the web service using ...
-6
votes
0answers
29 views
Is Race Condition being acomplished? [closed]
My aim is to simulate a race condition. In this code 10 pizzas are prepared by using makePizza method and are served to 20 different students using 20 different threads of a inner class PizzaServe. ...
3
votes
0answers
29 views
Dynamic voting protocol implementation for replicated file system
I recently implemented a dynamic voting protocol for a replicated filesystem. I would really appreciate it if you can review the design and some choices made with regards to sharing of Locks & ...
-4
votes
0answers
22 views
Need help in reviewing and fixing code [closed]
The code basically takes the http url available in a oracle table by using cm.getFile_name().
If the file download fails it attempts 5 times and then updates the record in the table with the ...
4
votes
2answers
59 views
Getting all the UTC “day stamps” between 2 dates
I need to get every UTC day stamp in yyyy-MM-dd format (e.g. "2015-07-02") between any two arbitrary Date fields.
My first attempt is this:
...
5
votes
1answer
50 views
A repeated string formatting operation
As I'm reading the Java code of some other people, I found him using an approach of assigning a format string to a variable and using the variable for String.format ...
4
votes
3answers
127 views
Implementation of Sieve of Eratosthenes algorithm
I have made an implementation of Sieve of Eratosthenes algorithm in Java, and am not certain that it is as efficient as possible.
I have looked at other peoples implementations on Google, and on this ...
4
votes
1answer
51 views
Create an object based on data from a text file
The following method reads specially formatted text (TOML) from a file and parses the input using a parser to get a few properties, which are then used to create an object.
The profiler tells me that ...
1
vote
1answer
41 views
Aggregation of files
I have millions of files in a folder. File types will be with the name PES_timestamp and DOM_timestamp. I have to aggregate all PES and DOM filenames into one file which has the same filename.
The ...
2
votes
1answer
37 views
-4
votes
2answers
85 views
Reverse the words of a string using Java [closed]
I wrote this program which reverses the words in a given string. Please review and give your inputs.
...
1
vote
0answers
20 views
Lookup map for converting Strings into Android `R.raw` integers
I'm currently working on an Android app and I need to translate keys of type String to Integers which are determined at compile ...