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)

0
votes
0answers
3 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
7 views

Reusable Properties File Reader

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
9 views
0
votes
1answer
18 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
407 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
46 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. ...
1
vote
1answer
22 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
15 views

Copying one list to another [on hold]

I am copying one ArrayList into another using an iterator: ...
1
vote
1answer
26 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
41 views
7
votes
2answers
328 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
71 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
26 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
30 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
31 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 ...
2
votes
1answer
25 views
-2
votes
1answer
13 views

ArrayList related method not functioning properly in main method [on hold]

Could somebody look over this code and see what I'm doing wrong? ...
2
votes
0answers
35 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 ...
2
votes
0answers
18 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
61 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 ...
2
votes
1answer
50 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
1answer
51 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
36 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
21 views

Could you give tipps for my Plugin System [on hold]

I made a Java plugin System but it feels a little blocky. Cloud you give me tipps? Github Repo
-7
votes
0answers
23 views

Java - TicTacToe with AlphaBeta pruning [on hold]

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 ...
-3
votes
1answer
44 views

Throw an exception, if all given objects are not present (null) [on hold]

Given some objects which when all being null should throw an exception. It may be written programmatically as follows. ...
0
votes
1answer
26 views

csv loader and kNN algorithm in Java

I have applied the KNN algorithm for classifying handwritten digits. the digits are in vector format initially 8*8, and stretched to form a vector 1*64.. As it stands my code applies the kNN ...
3
votes
1answer
57 views
+50

Querying the Google ads API

I have a method which relies heavily on object supplied by third party APIs. Below is my working code, is there any scope of improvement? ...
0
votes
0answers
23 views

Spring: Redirecting to a REST url on click

I have a page where a user can click on a link and send them to another url where the path variable is the user name. So example: user name is bmarkham. bmarkham is on www.website.com/welcome. ...
2
votes
1answer
53 views

Printing longest sequence of zeroes

I am doing a coding exercise in codility and I came across this question: A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ...
-2
votes
0answers
23 views

I am a begginer at using JavaJ++ [on hold]

My teacher wants me to create a Windows/Console application that asks the user to submit the correct password. Textpad keeps on marking errors in my coding. I would like to know more of how to use the ...
-2
votes
0answers
13 views

I have the length of each word from a file.I need the number of occurrences of each length(how many 7's,6's etc).I have this code so far: [on hold]

public class newc{ public void bla(){ FileResource resource = new FileResource("folder/my.txt"); ...
-1
votes
0answers
14 views

Java - Scanner is being ignored inside while loop but not elsewhere [on hold]

I'm in a bit of a pickle with my code as I can't understand why a particular user prompt is being ignored, when the exact same code is being used successfully elsewhere. This is an example of where ...
0
votes
1answer
41 views

Country lookup for locations in an array

I've got a method which get's a JSONObject as input which internally has a JSONArray. The problem is that one of values in the JSON Array is a country code, but when I return the final structure it ...
11
votes
5answers
736 views

Implement rate limiting by cookie ID

I want to develop a simple in-memory web request rate limiting module, I am allowed to have 50 requests from each unique cookie ID every 60 seconds. I am wondering if the following code is an optimal ...
3
votes
1answer
39 views

Java insertion sort implementation

I have written code for insertion sort. I just want some feedback whether the above implementation is correct and can be improved. ...
2
votes
0answers
32 views

Parallel merge sort in Java

I have rolled my own parallel merge sort. My performance figures are as follows: Seed: 1457521330571 java.util.Arrays.sort() in 6840 ms. Sorted: true java.util.Arrays.parallelSort() 3777 ms. ...
-4
votes
0answers
20 views

Using counter or constant for parameter position [closed]

Suppose that I have the following Java code: ...
-1
votes
1answer
69 views

Generic Factory in Java - EDITED [on hold]

I have a hierarchy of classes RequestParams , all can be created with ExtArgs. ...
-2
votes
0answers
28 views

implementation of remove method in simple linked list [closed]

I want to implement a remove method in my simple linked list : it removes a node in my list ... The implementation according to my teacher is like this : ...
2
votes
0answers
29 views

Android app that listens for commands over a socket

I've just begun programming Java and I'm working on the following code that deals with socket-based communications. Basically it connects to a client on port 8888: ...
5
votes
2answers
74 views

Counting occurrences of a word in a file

This gives me the output of how many times the word is in the file. (I will eventually want to enhance the program to output on what line of the file the word is.) ...
3
votes
2answers
37 views

SortedList implementation in Java

I've implemented a SortedList which takes in streams of floats and returns a median at any point. ...
0
votes
1answer
39 views

Finding Kth Permutation Sequence

I have written a program to display the kth permutation sequence of a string made up of letters 'O' and 'Z' . I tried optimizing it but my code have not passed test cases due to timeout issues.Looking ...
-4
votes
0answers
14 views

Draw Octagonal Grid [closed]

I have developed a program to draw Octagonal Grid. How do i write pseudo code for the same OCTAGON.java ...
4
votes
3answers
198 views

Using Enum to Handle String literals

I have a java component that was using a lot of string literals that I need to make comparisons on and return booleans based on these comparisons. In order to make the code more robust I externalized ...