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)

4
votes
1answer
29 views

Multi-threaded bitcoin vanity address generator written in Java

The application leverages the bitcoinj library to generate a vanity bitcoin address. A vanity address is simply a bitcoin address that contains a personalized string. I would like some critical ...
-4
votes
0answers
37 views

A basic Tic-Tac-Toe game programmed in Java

I have programmed a Tic Tac Toe game in Java using JavaFX for the UI. I have improved my previous version of the game after it got reviewed here. I will be highly satisfied if you can point out how to ...
-1
votes
0answers
40 views

Inverting a binary tree [on hold]

So I came across some code which is used to invert a binary tree, and it looks like this: ...
-2
votes
0answers
15 views

How to refactor, clean, and/or merge a massive code base efficiently [on hold]

We have a massive code base of over 8,000 Java, JavaScript, CSS, Java Server Page, and Spring-specific files. I have occasionally inquired about the ability to refactor certain files for readability ...
10
votes
3answers
437 views

Fastest possible text template for repeated use?

While reviewing Sending templatized e-mail to a million contacts, I wrote this implementation to illustrate an alternate approach. It is designed to be the fastest possible way to generate templated ...
-4
votes
0answers
11 views

About PokerHand Rule [on hold]

I never played PokerHand before and I do not understand the given test. Can anyone tell me why it shows two result(assertTrue(a.compareTo(b) < 0); AND assertTrue(b.compareTo(a) > 0);)? ...
1
vote
1answer
48 views

“Little Deepu and Array” challenge

I'm trying to solve this problem. I changed Scanner and used BufferedReader. Can I have a code review and know where else ...
5
votes
1answer
80 views

Sort all the characters according to their brightness

I wrote a little fractal noise generator the other day, and to test it I wanted to display the dark values with a darker character and the bright values with bright characters (I use a dark background ...
-2
votes
0answers
27 views

Inseting a node in binary search tree [on hold]

When I'm inserting a node on the below binary tree,it is giving incorrect answer,although logic seems fine to me. ...
3
votes
1answer
114 views

Duplicate integers in an array

Code shows duplicate values of integers in an array with indexes and the number of occurrences. Can you please critique my code and provide your thoughts on where I should improve my code? ...
6
votes
2answers
55 views

Java Swing Application - Roleplaying Aid

I've been working on this utility for a while now, and have since gone through a couple reworks to try and increase the readability and best practices, but since I don't usually work a lot with Swing, ...
7
votes
1answer
43 views

Number-guessing game with a cheat code

As my first Java program, I have written a number-guessing game. I would appreciate any suggestions on how I can clean it up or streamline it. I don't mean cut down on the general tasks executed ...
0
votes
0answers
25 views

Getting a String property of an Optional<> if present [on hold]

I am calling the getDetailOfUri(uri) method, which returns an Optional<PageDetail>, and I would like to set the strings ...
-1
votes
0answers
14 views

How to simplify this multi component gradle.build? [on hold]

I'm working on https://github.com/jadekler/git-java-websiteskeleton. It's a multi component skeleton with two components - products and users. I define an acceptance test gradle task at the root ...
1
vote
1answer
36 views

ArrayBlockingQueue - blocking drainTo() method

This is a follow-up question to this question. Is this a reasonable implementation for a blocking version of method ArrayBlockingQueue.drainTo(Collection)? ...
-3
votes
1answer
66 views

Converting from one collection to another

Basically I am trying to iterate over one collection moduleList and adding to another collection targetList Is this a good ...
14
votes
4answers
228 views

Numbers, pairs, and a difference

Problem statement: Write a function which returns the total number of combinations whose difference is k. For example, ...
-3
votes
0answers
37 views

How can I shorten this string? [on hold]

I have this which is used to enable GC logging: ...
4
votes
1answer
49 views

Unit Testing and good use of matchers

I been having discussion with colleagues recently about good use of matchers. Consider the following sample: ...
5
votes
1answer
61 views

Basic Java Swing Calculator

I am new to Java Swing and have decided to create a calculator to learn some of the basic. I would like someone to look over my code to see if they can give me any improvements. I have 6 classes and ...
5
votes
2answers
66 views

Project Euler #10 - sum of primes below two million

The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. ...
0
votes
1answer
35 views

Calculation of image offsets for performing cropping

I am using the java.awt.Rectangle class to construct subsets of a GEOTIFF file. In order to do this I would need to specify the x,y offsets, height and width of ...
10
votes
0answers
46 views

Getting chatty with FX

Applying a lot of unprecedented concepts here, it's a simple chat server capable of handling multiple clients, which are run through JavaFX, and have their individual threads instantiated and handled ...
5
votes
2answers
68 views

Basic game with moving objects in Swing

This is a simulation attempt of an "old-style game", where a "car" (nothing more than a red rectangle) must dodge some "obstacles" (blue squares) falling from the upper edge of the frame. If an ...
5
votes
1answer
57 views

JavaScript program to count lines of Java code

I've implemented a small program in JavaScript to count the number of lines of a string of java source code. This was done for one of the Code Kata exercise: ...
6
votes
2answers
95 views
+50

Singleton-ish RMI Server

In this program there is a single remote server which performs miscellaneous work. Because there is only one server, it seems like a singleton pattern could fit well. The problem that a distributed ...
0
votes
1answer
89 views

Java: How can I optimize the following code?

I have been trying to solve the following problem on hackerrank.com, but when I submit the code it shows unsuccessful submission due to timeout. Can anyone help me out ? ...
2
votes
1answer
242 views

Game server packet handler - follow-up

This is a follow-up question: Game server packet handler I have applied most of the suggestions and now the code looks like this: ...
12
votes
3answers
115 views

Weighted Probabilities with Integers for Game

The idea here is to pick a skill at random for the player each round. Four skills will be chosen, they are all random, and the same skill can repeat multiple times. The player has a skill level for ...
2
votes
4answers
65 views

Sending templatized e-mail to a million contacts

This code runs fine without a bug, I need to optimize this code for following interview requirement. Lets say i need to send it to 1 million contacts and emailBody is ~100Kb. What code optimization ...
2
votes
1answer
24 views

Harnessing hashCode as JAXB @XmlID in order to use it with @XmlIDREF

I have a class Fighter in a software for planning boxing events. I implemented its hashCode() and ...
10
votes
7answers
3k views

Determining the difference between odd and even numbers

I have code that converts each character of a String to an int and returns the difference between odd and even numbers. Can this ...
7
votes
1answer
54 views

Project Euler #7 using Java streams

I haven't written any Java in years and I wanted to catch up a little, especially on newer features. I started looking at streams and aggregate operations and came up with the following solution to ...
4
votes
1answer
63 views

SplashScreen class

I want to know about best practice for this SplashScreen class: ...
5
votes
1answer
54 views

Permutation algorithm of N unique elements with low memory footprint

I actually had a real life need (outside work, no less) to come up with every single permutation of N elements (the N in my case being 12, so a total of ...
7
votes
2answers
443 views

Servlet file uploader

I think this code looks ugly, especially with the multiple try-catch blocks, but I don't know how to rewrite it: ...
5
votes
2answers
103 views

Find the rarest in a map

Write a method rarest that accepts a map whose keys are strings and whose values are integers as a parameter and returns the integer value that occurs the fewest times in the map. If there is a ...
1
vote
0answers
28 views

Removing JLabels by pressing JButtons which disable if in excess

The goal of this code is to move some JLabels from (JLabel[] pileone) off a JFrame when a ...
5
votes
2answers
546 views

Unit testing private constructors and getter setters

I have a class Address, a class AddressTest and I am trying to write unit tests for its constructors and getter setters. ...
0
votes
1answer
31 views

Java constructor initialization practices [closed]

This code is just a simple idea which takes a query parameter and requests n number of third party services for the given query: ...
1
vote
0answers
30 views

Spring Security Web Configurer Adapter

guys. The code below is spring security web adapter. I do not like configure(HttpSecurity) method that generates security confirmation policy. Any ideas to do it more readable and clear? ...
1
vote
1answer
24 views

Simple Spring Service code

I used Spring MVC arch, and I need to be informed about correct names of methods and exceptions throwing. ...
0
votes
1answer
30 views

LeetCode Minimum Path Sum algorithm

I am attempting to solve the Minimum Path Sum algorithm problem and I have a working solution, however there was an unwritten requirement that the algorithm not exceed an unspecified amount of time ...
6
votes
1answer
66 views

Efficient top k words using MultiMap (Google Guava ext lib JAR)

Basic algorithm: Open document/huge text file Use Map and List to separate the words. \$O(K)\$ time complexity (TC) ...
4
votes
0answers
38 views

Bean Machine Simulation

I could not find a solution from my book's website (student-level access) but I feel that I am missing something that I'm supposed to learn from this exercise. Instructions: Balls are dropped from ...
1
vote
2answers
93 views

Project Euler #9 implementation in Java

Question: Special Pythagorean triplet, Euler Problem 9 A Pythagorean triplet is a set of three natural numbers, \$a<b<c\$, for which, $$a^2+b^2=c^2$$ For example, ...
2
votes
1answer
17 views

In a Content Pane mouse movements are logged and shown

I was trying to learn to develop plug-ins in Eclipse and after following the tutorial provided with Eclipse, tried to expand the code by writing a short Java class to track and display mouse movements ...
0
votes
1answer
41 views

Print Java Object graph

Please share your comments and better ideas, to print java graph, which manipulates selected (@Mask) fields as XX, thus avoid logging confidential data, through ...
5
votes
4answers
276 views

A data structure with push(int x), pop(), min() and max() in O(1)

I have written this Java code for a data structure which includes 3 stacks to supports four operations in \$O(1)\$: push(int x), ...