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.

learn more… | top users | synonyms (2)

3
votes
0answers
14 views

Sudoku Solver - uses DFS and Constraint Propagation

Disclaimer: My code is translated from Peter Norvig's Python code. This simple code uses only two techniques: Constraint Satisfaction and Depth-First-Search. Backtracking is not implemented. Here's ...
0
votes
2answers
18 views

Initialization lock for singleton

I'd like someone to double-check my use of Atomic primitives, because multi-threading is hard. What I don't want to do is locking the whole get method, or having too many pre-checks per get() call. ...
1
vote
0answers
13 views

Synchronization of new data with previous data

I am working with synchronization for the first time. I wrote some code that I have to implement in my current work. I wanted to know if I am doing it right or am I making a mistake. Whenever a new ...
0
votes
1answer
9 views

Converting javax.security.cert.X509Certificate[] to java.security.cert.X509Certificate[] keeping order

I have got an array of javax.security.cert.X509Certificate and need to convert it into an array of ...
3
votes
2answers
55 views

The Game of Life that scored 100%

Note, this is from a COMPLETED course. This is not a ploy to get help with homework as I have already received a 100% on this assignment (last year). I just want become a neater programmer. Can you ...
2
votes
1answer
14 views

Base Changing in Java, improved version

This is a follow up to my previous question, Base-changing numbers in Java I have followed @Pimgd's advice in the answer to that question, and I'm posting the improved code for any further review. ...
3
votes
2answers
42 views

Hackerrank Cut the sticks Solution

I have started learning Java recently and I solved the following problem on Hackerrank. The challenge is to : You are given NN sticks, where the length of each stick is a positive integer. A cut ...
4
votes
1answer
85 views

Edit method, doing multiple checks for tracking changes vs the one in database

I am working on a Spring-MVC application in which there are around 2-3 methods which are quite big and complex, but only one of them worries me, especially for maintenance or changes. As changes in ...
-4
votes
0answers
15 views

Pebble Game algorithm [on hold]

Pebble Game algorithm /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1
vote
1answer
27 views

Class to read the property files

I wrote the following code to read the config/property files. I will be exposing my api as jar to multiple application teams. Functionality: Reads the property files and returns the resource bundle ...
0
votes
2answers
35 views

Sorting List on basis of certain letter

I am trying to sort a list on basis of C before . Is there better way to do this? ...
3
votes
1answer
46 views

Base-changing numbers in Java

On a whim, I came up with this program to act as a helper class for base changing, if I require it in the future. It was made to support fixed-point and negative inputs, but they are basically a hack. ...
3
votes
1answer
43 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
20 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
79 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 ...
4
votes
1answer
38 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
198 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
47 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
34 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
46 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
23 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
63 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
31 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
32 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
47 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
71 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
79 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
35 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 ...
1
vote
0answers
24 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
189 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
23 views
0
votes
1answer
24 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
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
341 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 [closed]

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
29 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 ...