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.
3
votes
1answer
24 views
Basic structure for interactive single window application
This is the basic structure I usually end up with whenever I'm writing a simple application. More recently I've learned about singletons and have started to incorporate them into my design, but other ...
0
votes
0answers
17 views
Stale socket connection leak [on hold]
I am currently reviewing Oracle's examples how to manually follow referrals (case throw) in Java/JNDI returned from a directory server via LDAP. The example source ...
4
votes
1answer
66 views
Easy Game of Life project
I've developed easy Game of Life project. I'd highly appreciate any feedback and possibilities to improve my code, both in efficiency and style. It works on list and it's terminal program.
ICell.java
...
3
votes
0answers
26 views
Java NIO server Selector loop
I have a server that uses Java NIO in non-blocking mode. Right now I'm using a single thread for the selector, and four worker threads to process the bytes after ...
-2
votes
0answers
193 views
Need urgent help on this simple multiplication code [on hold]
I have this code that gets the product of two numbers using the Long Method Multiplication I only have 3 hours to get this done or I'll fail my Subject.
The program will ask you to input two numbers ...
3
votes
1answer
42 views
“Space and Time Efficient” way of finding all anagram groups
I have written a program to find all anagram groups in a text file. I used first 26 Prime numbers as a mapper for 26 characters for finding anagram groups (Since character_set of all anagrams of a ...
3
votes
2answers
29 views
AES and RSA using javax.crypto
So I am assuming that I did something wrong, and my AES and RSA encryption and decryption classes are insecure. I plan on using them for a larger project, and want to make sure I didn't completely ...
3
votes
1answer
43 views
Comparing a string that can hold a numeric value
I am refactoring a part of big old system developed in Java. I came across a situation where we are migrating some data types, and there will be use of both types. For compatibility, as all the old ...
-5
votes
0answers
20 views
Vending Machine Code Java, how so i do this [on hold]
OKay guys I'm trying to work on a vending machine code and not sure how to approach this. Here's what I have to do:
Vending Machine ***:
Write a program that mimics the operations of a vending ...
-3
votes
1answer
61 views
Four-function calculator with a text menu
This code works but I don't know if I am doing this correctly. I want to have a do-while loop for the menu and app. How could I ...
0
votes
0answers
28 views
Progress indication with animation
I have a game in which the player has to do something within a defined time.
E.g.: the player has 10 seconds to complete a level.
My current code animates an imageview (it's only a horizontal line) ...
0
votes
0answers
9 views
stack to determine if a string of characters is a palindrome [migrated]
I'm getting cannot find symbol error on Stack stack = new Stack(str.length());
I can't find any reason why this is not working please help.
...
0
votes
0answers
31 views
Applying “Tell, don't ask” to show objects from database on screen [on hold]
I'm looking for a review of my code. It's aim is to show objects retrieved from database on screen without any getters or another ways to ask objects for data.
To achieve it, I used Command pattern:
...
3
votes
2answers
43 views
An assembler for ToyVM
After rolling my own virtual machine, I decided to implement an assembler for it. Ironically, it's all Java, since I needed to do a lot of text manipulations. Here is the main component:
...
2
votes
0answers
68 views
Number-to-words translator
I've created a class that translates an integer into words in an English (not British) format. My first human language is not English, and I don't have a good idea of a truly right way to read ...
5
votes
1answer
75 views
Reading a properties file using design patterns
I am trying to read properties file using a singleton class. I would like to know if there are any best practices and design patterns to read the properties file. I found dependency injection is one ...
1
vote
1answer
65 views
Java Stack Implementation with Generics
I've written an implementation of a Stack data structure using a linked list.
Stack.java
...
1
vote
1answer
34 views
Pretty handling FileNotFoundException
I have got a piece of code that initialize Scanner in two possible ways:
no argument constructor creates Scanner that uses stdIO (System.in) as source
contructor with String, which creates Scanner, ...
7
votes
4answers
2k views
Selecting an enum for a payment transaction
I'm writing a small Android application that deals with payments and, in my function that handles transactions, I need to translate a number of installments (1-12) and whether or not it has interest ...
-6
votes
0answers
28 views
0
votes
0answers
22 views
Pong game in Processing with Java
I programmed a Pong game in the Editor Processing! I would be glad if you could rate the code and give some improvements ;) Thanks a lot!
...
2
votes
2answers
188 views
Implementation of Abstract Factory pattern with different vendors for product
I am studying about design principles and design patterns. I have implemented an Abstract factory pattern as per my understanding. The scenario I have considered is as follows :
There is an ...
0
votes
0answers
17 views
Reusable Properties File Reader [duplicate]
I have implemented a properties file reader. The goal behind creating the properties reader is to cater to different application teams to import the class and read the properties in their projects.
...
-4
votes
0answers
22 views
java.lang.NullPointerException when trying to upload excel value to database [on hold]
My code to read file..
...
0
votes
1answer
23 views
Do CriteriaQuery code more readable and elegant
I wrote the code and would like to change it to more readable and elegant:
...
8
votes
3answers
457 views
“Magic Squares” assignment
The assignment is to take a "Magic Square" .txt file (where the horizontal lines, vertical lines and diagonal line all add up to the same number), read it and prove that they are in fact magic ...
-1
votes
0answers
12 views
Java Singleton design pattern [migrated]
Can someone explain how my Junit passed successfully with below singleton implementation
EagerInitializations.java (singleton)
...
-3
votes
0answers
61 views
3
votes
1answer
51 views
Vertical Text Printing (Java)
I was trying one of the problems found on HP Codewars 2007: (2)
Task Description:
The CodeWars judges and scorekeepers need help printing the team names above each column on our score sheet. ...
2
votes
1answer
39 views
Find all instances of a given weekday in February for a given year
A friend of mine was practicing his programming skills with a textbook meant to prepare students for computer science exams. He asked for help with a specific task.
The task is to capture user input ...
0
votes
0answers
8 views
JUnit @Rule ExpectedException [migrated]
I have been trying to use the JUnit expected Exception to validate my own exceptions for an application, however whenever I try to use this the compiler complains that there is an uncaught exception.
...
-1
votes
0answers
16 views
Copying one list to another [on hold]
I am copying one ArrayList into another using an iterator:
...
1
vote
1answer
27 views
Custom OrderedLinkedList class with nested OrderedListNode class
Everything works with this program. It takes both Strings and ints, however, I feel like my add method is simply too verbose. Does anyone believe I can implement a shorter version of this, or is it ...
1
vote
2answers
45 views
7
votes
2answers
336 views
Program to index a book
Indexing a book. Write a program that reads in a text file from
standard input and compiles an alphabetical index of which words
appear on which lines, as in the following input. Ignore case ...
-5
votes
0answers
28 views
DTW memory usage in Java [on hold]
I have found the Dynamic Time Warping (DTW) library which coded in Java. Floating point array (...
-2
votes
1answer
75 views
How to make my algorithm faster
I know my algorithm is very naive and slow for this problem. I would like to learn how to improve upon it?
...
0
votes
1answer
28 views
Custom concurrent stack implementation in Java
I don't want to use synchronized for sizeof method, any suggestion to implement the method thread safe?
...
2
votes
0answers
34 views
Roman numeral converter project
I have a project that is due for my Intro to Java course which requires me to translate the number range of 1 - 3999 into Roman numeral form. If the number I pick is 0 it will end my program, anything ...
2
votes
1answer
33 views
Comparing two shuffling methods
I'm trying to randomly shuffle an collection of integers within a List and I have came up with two shuffling method that does the job. However, I'm not sure which ...
3
votes
1answer
28 views
-2
votes
1answer
13 views
ArrayList related method not functioning properly in main method [closed]
Could somebody look over this code and see what I'm doing wrong?
...
3
votes
0answers
39 views
Basic game engine: timer, FPS and logic loop
I'm creating a simple Java game engine (just for fun). The idea is to create a basic framework for developing any kind of 2D game, an abstract engine that does the hard work. Would you like to review ...
5
votes
2answers
72 views
Showing object's data on GUI and HTML without accessors and mutable objects
I have been searching for a solution to show data of class with three assumptions:
Class Employee is not responsible for showing itself
Class ...
6
votes
1answer
71 views
Can my cache be more thread safe?
I have been working on a cache that can handle multiple reads at the same time, but the write is blocking.
Is this code overkill by using both a ConcurrentHashMap ...
3
votes
1answer
55 views
Method to convert numbers into plain text
I'm relatively new to Java, and over the past week or so I've just been reading through the docs and messing around with it to better improve my understanding.
As stated in the title, I've created a ...
2
votes
2answers
62 views
Java Doubly Linked List Implementation
I recently submitted an implementation of a singly linked list and tried to apply some of the suggestions on this implementation. I decided not to implement the List interface as I only wanted to ...
4
votes
0answers
38 views
Shortest path navigation across a grid using Best First Search
The code below is an implementation of the Best First Search algorithm for navigation of the shortest path across a 2D NxN matrix. As a heuristic for the search I use the standard distance formula. ...
-2
votes
0answers
22 views
Could you give tipps for my Plugin System [closed]
I made a Java plugin System but it feels a little blocky.
Cloud you give me tipps?
Github Repo
-7
votes
0answers
24 views
Java - TicTacToe with AlphaBeta pruning [closed]
I'm trying to implement a minmax algorithm with alpha beta pruning in a tic tac toe game in java. The code appears to be right but when I call the main cMove ...