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.
1
vote
0answers
22 views
Mapping one JSON message format to another in Java
This code takes a JSONObject, passes it to another class which is responsible for mapping the data in the JSONObject to a different format (Still a JSONObject though).
I'd just like confirmation if ...
0
votes
1answer
20 views
find prime positioned prime number
This is a question from programming contest. This contest is already over.
Now, all the prime numbers are arranged sequentially in ascending order. i.e:- 2, 3, 5,7...and so on. Now, your task is to ...
-4
votes
0answers
20 views
What should I change in this java project to look like an java expert? [on hold]
I'm really confuse about the interview I did with a firm. They told my code was not expert, but almost intermediate level java.
Basically, the problem was to create a scoreboard to print the game ...
-1
votes
0answers
10 views
4
votes
1answer
19 views
Invoking API calls with parameters specified using JSON
I have an instance of a Java class that I need to call some functions on, using the API exposed by another party. For each call, I need to both check for thrown exceptions, and check the value of the ...
3
votes
1answer
33 views
Java - Creating a Paginated List
I need to create a class which acts as a paginated list. My use case is like this:
I am writing a library which makes a service call to fetch a List<obj>. ...
5
votes
2answers
51 views
Calculating the perfect squares between two given numbers
This code is for calculating the perfect squares between two given numbers. User can add the interval as well like for how many intervals he want to check the perfect squares. For example if user ...
0
votes
1answer
9 views
Suggest me some improvements so that i could reduce the execution time less than 4 sec for any testing value
Here is the Code.
This code is for calculating the perfect squares between two given numbers. User can add the interval as well like for how many intervals he want to check the perfect squares.
...
0
votes
1answer
79 views
Cleaning up 3D bin packing [on hold]
This is a follow up question to 3D bin packing in java (compare two codes)
I finished testing my code's result and started cleaning it up.
Could anyone please tell me what I should do or fix to ...
0
votes
1answer
23 views
Modbus connection over TCP and Serial port
I want to improve my code. In this code I don't like my contructor, but without it I keep getting an error while trying to connect NullPointerException.Any ...
2
votes
1answer
27 views
3D bin packing in java (compare two codes)
I made some changes to the first code here I wrote and I want to know which one is more correct logically (before the changes or after the changes)
It's really hard to manually test these kind of ...
6
votes
3answers
829 views
Simple Hangman game in Java
I'm teaching myself Java and I had some basic questions on how well I am writing my code for readability. I feel like sometimes I'm just writing code that works, and I'm not that proud of myself when ...
-1
votes
0answers
28 views
A console-based bingo game in Java [on hold]
https://github.com/qbolt/Bingo
I created this for a class assignment and I wanted to do it in an object-oriented way. I haven't really shown anyone my code before and none of my teachers thus far ...
7
votes
1answer
61 views
Checking for surrounding mines
Am trying to create a minesweeper game, I have the following code which has to many nested ifs, I want to change the code to take out the nested ifs and make it better to read. But I am stuck on how ...
3
votes
2answers
42 views
The Boyer-Moore Majority Vote Algorithm
I have started learning Java recently and was looking into some easy algorithms.
I found the Boyer Moore voting algorithm here.
I am trying to get better at writing good code for my solutions. Please ...
2
votes
1answer
31 views
Displaying a String array in tabular format
I have an array of strings called theArray. All strings in theArray are of length 20. I wish to display this array in tabular ...
3
votes
1answer
28 views
3D bin packing algorithm using Java?
I wrote a 3D bin packing algorithm but I am still not sure if it is correct or not.
I did not follow any code or pseudo-code that's why I would like to know if it is an efficient algorithm for the 3D ...
0
votes
1answer
26 views
Generic matrix in Java supporting arbitrary rotations in constant time
I have this generic "matrix" holding elements of arbitrary type. It supports any horizontal or vertical rotations (of any step size) in \$\mathcal{O}(1)\$. See what I have:
...
2
votes
2answers
140 views
Find the highest unique element in an array
Here is my approach. Unique element means that element should present only once in the array.
...
-1
votes
2answers
45 views
Validation logic for range check with input can be String or Number
Requirement
Validate two inputs (from and to). Input can be either Number or String (value hast to be date in UTC format)
...
-4
votes
0answers
32 views
Displaying all possibilities Java [on hold]
I've found a simple program for displaying all possibilities of String from given letters and the size of that String. Could you explain for me the for loop? I ...
-2
votes
0answers
11 views
Postfix Evaluation [on hold]
I'm having a hard time understanding whats wrong with my code. When ever I go to run the application program, I get an Empty Stack Exception
...
4
votes
1answer
34 views
Evicting an entry from a size-limited HashMap<T, Integer>
I have a HashMap with a limited size of 1000 elements. When I want to put one more, the T with the lowest related Integer in the map should be replaced with the new one.
I already have this working ...
0
votes
0answers
24 views
Filtering based on actions and keywords
I have an Android function that when an intent is passed, it filters based on the actions and keywords. How can I improve this function?
...
6
votes
2answers
98 views
Very Simple UNO Game
I made a simple text-based UNO game in Java. It lacks some features of the original game, but it's good enough for now. I'm new to Java, so I would like to receive as much feedback and suggestions as ...
0
votes
1answer
16 views
Design of thread pool reuse with Executors.newFixedThreadPool in Java
In my application I have code which should run every hour on a new items and execute some expensive operation with multithreading:
...
1
vote
1answer
42 views
Methods to check form validity and to count invalid form fields
I have two these methods. Their loops are pretty similar. I'd like to refactor it to avoid duplicate nested loops. How could I do that?
...
1
vote
2answers
39 views
Game engine for 2D games in Java
I am writing a 2D game engine library that I can use for simple future games, and I've been told that it is written very procedural rather than objected oriented. I was wondering what I should do to ...
3
votes
1answer
51 views
Two solutions to Project Euler 12, but one is drastically faster
My code for #12 (first triangular number with over 500 divisors) is as follows:
...
2
votes
1answer
56 views
Quiz program in Java
I have made this small quiz with 10 question and 40 JRadioButtons. One question and 4 JRadionButtons for each panel. So I had to ...
2
votes
0answers
49 views
Sudoku Android Code
I have been programming for a long time, but nobody has given me any feedback if my code is good or not. Please review it, and give me feedback where I could be better.
The source code is also on ...
0
votes
1answer
49 views
Enhance the performance of the source code in Java
I need help to enhance the performance of java source code. The code take txt file that has name, amount and date in form (name) (amount) (date yyyy-mm-dd) separated by spaces. After reading the file ...
0
votes
0answers
25 views
AVL Tree Array Representation
In a school assignment I'm supposed to create a program simulate insertion, deletion, count nodes, and delete tree algorithm and displays the traversal, level order, and array representation of it. ...
2
votes
2answers
95 views
Given a string S and Q query strings(q1,q2,…), check for each query string whether or not it is sub-sequence of S
Here is my approach. Subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.
...
5
votes
0answers
28 views
Thread-safe algorithm to make trades based on moving window of prices
Here is problem to be solved
TradingAlgorithm employs a trading algorithm which, based on the prices it receives, will return a trade to execute.
The trading algorithm must implement the ...
4
votes
1answer
44 views
Printing the right diagonal of a matrix
I am solving a coding challenge whose objective is to print the right diagonal of a matrix. And below is my code to do that.
...
3
votes
1answer
65 views
Parsing speech out of text
I'm working on an experiment to parse speech out of an emote in a text roleplaying game (MUD) so that if you can't hear it correctly, or if it's in a different language, you won't understand it. This ...
5
votes
1answer
42 views
Deterministic finite automaton in Java
Formally, a deterministic finite automaton is a 5-tuple \$M = (Q, \Sigma, \delta, q_0, F)\$, where
\$Q\$ is the set of all possible states
\$\Sigma\$ is the alphabet
\$\delta \colon Q \times \Sigma ...
-3
votes
0answers
14 views
9
votes
2answers
84 views
Java hex dumper
Can somebody please try and help me speed up my code? The file is ~12MB (you can download it here). It takes around 500-600 milliseconds to run on my i7 4790k.
...
-2
votes
0answers
23 views
MSD Radix Sort in Java [closed]
I wrote the code for most significant radix sort but I keep getting an error of IndexBoundsException on the line: arr[i] = arr1.get(i);.
...
3
votes
1answer
59 views
Conway's Game Of Life in Java
I've written a simple demo for Conway's Game Of Life for self-practice.
How can I improve the code, especially the processLife() method which traverses and updates ...
2
votes
0answers
24 views
Speed Up Twine Cipher for Java Card
I implemented the lightweight cipher Twine described
here but it seems to me that this is not sufficiently optimized.
For example, below I have the key expansion for 80 bits:
...
5
votes
2answers
61 views
4
votes
1answer
31 views
Pulling from data from SQLite DB on Android
Apart from merging the 2 get methods, what else can I do to optimise this?
Both input and output cannot be changed. Is there a way to iterate a map while writing to it?
...
4
votes
0answers
50 views
Swing UI to display and edit terrain for a game
I would like someone to review my code and maybe give me some advice to maintain it because I'm still a beginner.
...
2
votes
3answers
368 views
Generic methods to find the maximal element in part of a list
This is the question from Oracle docs:
Write a generic method to find the maximal element in the range
[begin, end) of a list.
I had my implementation like this:
...
-2
votes
1answer
30 views
Writing clean and efficient recursive function
How would you rewrite this function, to be as much readable as possible, while containing minimum lines and being not much slower:
...
4
votes
2answers
87 views
DAO to create, update, and delete a project
I'm trying to write my first "complex" program in Java. So far, I created a local H2 database but I'm not sure about the quality of my code (I'm newbie in Java) because I don't know how I can deal ...
1
vote
2answers
62 views
Converting and enriching an array of data
The method below converts an array of TheatreListData objects to an array of TheatreListDataWrapper. It also loads additional ...