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.
2
votes
0answers
31 views
Building an efficient bubble sort function
I've been asked to create a bubble sort function that checks whether the array has been filled sorted before all passes are complete, thereby avoiding unnecessary passes. This is to involve ...
3
votes
1answer
35 views
Line passing the most number of points
Given points on a two dimensional graph, find a line that passes the most number of points.
Any comments please?
...
5
votes
1answer
44 views
Hangman program in Java
Here's an implementation of Hangman using Java 6. I've split the code into 2 classes - a logic class & a gui class. Is it ok to have so many static member variables? Please let me know if there ...
5
votes
0answers
22 views
YAuB - Micro Benchmark Follow-on
Following some great advice here from Simon, I realized that I had over-engineered things, and that the Task builder methods were a horrible Java8 abstraxction. In Simon's words: "From a usability ...
4
votes
2answers
325 views
Non-recursive method for finding a ^ n
I am working on an interview question from Amazon Software. The particular question I am working on is "to write a program to find an."
Here is my recursive solution to this problem (in Java):
...
3
votes
0answers
26 views
Creation of Queen Ann's Lace fractal
I've created a program which recreates the Queen Ann's Lace fractal. However, when the amount of points that are being plotted increases, the points are plotted way slower. Is there any way to make it ...
6
votes
1answer
27 views
Parsing log files of HearthStone: Loading card data without external libraries for JSON
I'm still working on a parser that can parse log entries from a game called HearthStone, the overall idea is that it will read the log file live when the game is running, parses the log file and show ...
1
vote
0answers
13 views
Read from DataInputStream (Socket connection)
I am interfacing with a network device and must read a response after I issue a command. Sometimes when I attempt to read, nothing has been returned from the terminal. This means I must wait, but not ...
2
votes
0answers
20 views
JSON extraction
Given the code below, is there a better way to essentially create different native objects without changing the native constructor or the nativeList.json file? The only option I can see is adding a ...
5
votes
3answers
362 views
Nested loop to render tiles in a grid
This code works but I'm not really sure if I wrote it good enough. It seems a bit vague but I can't really assess it properly. I'm particularly concerned with the ...
-1
votes
0answers
12 views
WLP (Weakest Liberal Precondition) Transformer implementation in Java? [on hold]
Input for our program is array of instructions (Expression [] instructions). Then iteratively starting from last instruction, and going backwards we searching for weakest pre-condition of single ...
2
votes
3answers
195 views
Generate all possible numbers which can be representated as the sum of 2 cubes below N
I have written a program that generates all possible numbers which can be represented by adding 2 cubes which have value less than N
For example: when \$N = 10, 1^3 + 2^3 = 9\$
...
7
votes
3answers
143 views
Return list of common email ids from a list of lists
Input: ArrayList of ArrayLists with email ids.
Output: Return ArrayList of email ids which appears in each inner ArrayList.
Ex: Input: [[[email protected], ...
8
votes
1answer
46 views
YAuB - Yet another Micro Benchmark
Note -> Follow-on question posted here: YAuB - Micro Benchmark Follow-on
I recently answered this Beautiful String question, where the task is to maximize the value of a string by assigning each ...
18
votes
4answers
1k views
Calculate distance using speed of sound
I've been working on learning Java and this was a challenge as part of a chapter on data types:
Create a program that computes how far away, in feet, a listener is
from a sound. Sound travels ...