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.
0
votes
1answer
11 views
Wrapping class for adding elements to HashSet
I have many object of class Test. I want to be sure, that among them there are no two objects o1 and ...
0
votes
0answers
11 views
understanding synchronized keyword on AdapterManagerImpl a class of sling framework [on hold]
I'm researching how sling framework work behind the sence. But my knowledge on multi thread programming is very limited to understand what they are doing, here's my issue:
This is the class i'm ...
0
votes
0answers
9 views
Frogger game in Java [on hold]
I am new to coding in Java,
I have familiarized myself with enough to get this far in a Frogger clone (I use the term clone loosely).
I'm not sure if I am allowed to simply link to the code - but ...
3
votes
1answer
56 views
Producer Consumer using custom blocking queue
After the feedback I have got from this question, I tried to to re-implement the classic Producer Consumer problem using multithreading.
The requirements are:
If the queue is not full, all the ...
2
votes
2answers
75 views
Returning a different but similar “increasing” string depending on instance argument
I have to work with a function that takes an instance of a class as an input, and depending on that instance, I have to return a specific string. It works, but it has a lot of repetitive code. How can ...
0
votes
0answers
25 views
Better way to deep copy than this? How can I make it generic by `Collection` type?
Could I make this method for deep copy generic to the Collection type?
That method is so simple and I can't imagine ever needing to change it, so maybe I should ...
1
vote
1answer
21 views
Get time table from 4 attributes
I have an entity with opening and closing times and I have to list timetable in HTML label.
Times can be empty.
Ugly attribute names ...
5
votes
2answers
38 views
Summing random numbers in parallel
I am playing around with parallelization in Java and am trying to see how to squeeze out more performance on my multi-core box. My machine has 6 physical cores, 12 with hyperthreading.
However, with ...
-1
votes
0answers
13 views
Reset the pointValue when a player wins or loses a game of craps [on hold]
I am trying to reset the players point value once a player wins or loses but I cannot figure out the best method of approach with my current code. I have tried resetting the pointValue.setText("0") ...
-2
votes
0answers
28 views
Sorting algorithms fail on large arrays [on hold]
I am trying to sort the arrays using different algorithms. When I run the application with small number of arrays, it works and produces the results. When the arrays are larger than: 65536, it stops ...
0
votes
3answers
36 views
Implementing multiple Producer Consumer using custom Blocking queue [on hold]
I am trying to implement multiple producer multiple consumer problem using a custom blocking queue. The requirement is that:
If the queue is not full, all the producers should be able to produce ...
-2
votes
0answers
20 views
Method to draw rectangle [on hold]
I created method which returns true if point belongs to Equilateral Triangle.
When I want to draw it (coordinative system has point (0,0) in upper left side of screen) I get the fine Equilateral ...
6
votes
1answer
142 views
Finding anagrams
I recently had a potential employer send me a programming test to read through a file and write to another file all the words that were anagrams (two or more words containing the same letter). The ...
5
votes
1answer
40 views
Affordability/Mortgage Calculator
I'm working on a class project for my intro to Java class. My background is in accounting/finance so I decided to make this simple calculator that helps the user decide what they can afford and how ...
0
votes
1answer
48 views
Computing even huger Fibonacci numbers in Java
I have that method for computing Fibonacci numbers \$F_i\$ (\$i = 0, 1, 2, \dots)\$, that relies on computing
\$
A =
\begin{pmatrix}
1 & 1 \\
1 & 0
\end{pmatrix}^n.
\$
The solution is then ...
1
vote
1answer
52 views
Gathering metadata on files in GitHub
I am a relatively new programmer and am currently working on something with the egit GitHub client library which requires me to iterate over a bunch of values and if a condition is met, add a bunch of ...
-3
votes
0answers
38 views
2
votes
2answers
709 views
Computing huge Fibonacci numbers in Java
I have this small Java program for computing particurly large Fibonacci numbers (10000th Fibonacci number is computed in about 220 milliseconds). The key idea here is to use lists of digits, which is ...
1
vote
0answers
13 views
Label with subTitle
This code shows a title with an image and subtitle:
What improvements can I make in this code and is there a better of doing this?
...
1
vote
1answer
27 views
Handling 8 toggle buttons in a point-of-sale application
I am self-taught and trying to improve my programming skills. My project is a point-of-sale application, with lots of buttons. I am curious how improve this section of code, as I seem to be going ...
1
vote
2answers
51 views
4
votes
1answer
101 views
Animal inheritance hierarchy
I'm trying to figure out if I'm doing superclasses right. Also, I welcome critique on Java structure/syntax etc.
Animal.java:
...
-2
votes
0answers
40 views
implementing a priority queue with a binary min-heap using an array list [on hold]
Im not sure how to test this code, but I think it is correct implementation.
...
-3
votes
0answers
29 views
Printing a string several times [on hold]
Given a non-empty string str like "Code" print a string like "CCoCodCode". Where at each index in the string you have to reprint the string up to that index.
...
3
votes
0answers
55 views
Constructing NewsArticle objects from a database table
This class seems to be able to represent the data stored in any possible database table:
...
5
votes
4answers
421 views
Simple BMI calculator in Java
A similar question must have been asked a thousand times, but for the life of me I can't figure this out. I am new to Java and I want to create a programme that asks a user for his or her height and ...
-2
votes
0answers
21 views
Code optimization for java code that reads the data from the excel file
The following code snippet reads the data from the workbook(Excel) and stores it as list of row objects.
...
-5
votes
0answers
20 views
e^x = 1 + x + x2/2! + x3/3! + x4/4!+… << e to the power equation using java method [on hold]
What am I doing wrong here? I just can't figure out what is wrong with this code.
...
3
votes
2answers
78 views
Java Temperature Converter GUI
Today is my first time working with GUI, so I'm really interested in the best ways of handling various events to get the best habits from the jump. Most of the GUI-related code for this project was ...
-1
votes
0answers
20 views
Comparing the ages and names of 2 people [on hold]
I am pretty new to Java and I'm having troubles on a few sections of my code. The program I'm trying to make is designed to take in the name and age of 2 people and tell them whether or not their ...
1
vote
0answers
25 views
Print all possible sequences that could have created this BST
I was working through Cracking The Coding interview, and I couldn't wrap my brain around their solution to one of the problems, so I ended up coming up with my own that, IMHO, is a lot cleaner and ...
5
votes
1answer
48 views
Brainfuck to Java converter
Similar to the previous post Brainfuck Interpreter: Slower than a Snail?, it runs BF in java. The only difference is that the converter will convert the BF code into a compilable and fairly readable ...
4
votes
2answers
65 views
Reverse all the words in a given string
I have read this and I want to know how the solution that I came up with in my interview compares with the top solution.
...
3
votes
2answers
77 views
Improving Least Recently Used implementation in Java
I wrote implementation of LRU in java and want to know if it can be improved further both in space and time complexity.
Input: Number of frames and reference string for pages.
Output: Number of ...
-3
votes
0answers
14 views
binary search tree in java [on hold]
I am trying to write a java code for binary search tree.The program includes insert,delete,check empty and print features for tree.But I am not able to insert nor delete any node in the tree.please ...
-5
votes
0answers
23 views
6
votes
1answer
117 views
Printing even and odd using two concurrent threads
Please review the code below where thread Odd prints all odd numbers from 1 to 9 and thread Even prints all even numbers from 2 to 8. I tested it and it works but can we improve it from design or ...
-1
votes
0answers
19 views
Obtaining Input from Button and convert to double [on hold]
I'm new to coding and making a calculator. I want to obtain the input from the button (in this example, I'm using the 9 button-code), which is a String, and convert ...
5
votes
1answer
33 views
Editing Javascript and rendering HTML in one window
I've been trying to learn the basics of Javascript, so this afternoon I put together a small JavaFX application that has a raw text area on the left, and an HTML rendering on the right:
...
6
votes
1answer
180 views
Brainfuck Interpreter: Slower than a Snail?
Inspired by FizzBuzz by Brainfuck, I decided to write an interpreter for Brainfuck. It:
Removes all non-command characters
Optimizes commands (removing +- and ...
5
votes
1answer
48 views
Random number generator initialisation
For a server-side Java application I want to have a random number generator. I'm using the ISAAC algorithm from Apache Commons Math 3 because it is both cryptographically strong and fast. I have ...
-3
votes
0answers
21 views
Message on chat application is send only when server and client presses send button [on hold]
I've done a simple app in Java that sends a message using a port & socket. The problem is that whenever I press Send button, the app freeze and waits for clients to press the Send button in order ...
1
vote
0answers
46 views
Passing the name of a class to the UI
I've extended FragmentPagerAdapter but reading the example implementation automatically generated by Android Studio's "tabbed application" preset, ...
-1
votes
0answers
13 views
Reuse URLs in a resource with jersey-spring 1.19 [on hold]
I'm working with jersey 1.19, the order resources detail depends of the order that I'm requiring:
...
6
votes
4answers
154 views
Generate valid random rgb color strings
I'd want to see if is possible to optimize performance even further of the following generate color method.
...
1
vote
0answers
43 views
AVL tree implementation
So I've just created an AVL tree in Java. However when I test its running time using the following code:
...
0
votes
0answers
21 views
Compressing a list of intervals [closed]
I need to compress a list of intervals into a smaller list. Let me explain:
For example I have a list containing intervals [1,4],[2,5],[5,7],[10,11],[13,20],[19,21] and i want to join the intersecting ...
3
votes
5answers
104 views
Two integers start and end
Write a program that reads two integers start and end from the user
and prints the number from start to end inclusive. However, If end was
less than start than you should print them in ...
-2
votes
0answers
20 views
Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException Error [closed]
I'm a newbie in Java and I'm trying to create a two player combat game in which the moves of the player are controlled by keyboard.As i didn't find any error in syntax or structure but it throws a ...
0
votes
2answers
56 views
Transforming CSS into an encoded representation
I have a java code that is supposed to format the content of a .css file so that I could use the result to make a enum class.
...