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)

-1
votes
2answers
63 views

Using Java 8 streams for finding Persons with maximum numbers (Codeforces-151B)

See Problem - 151B - Codeforces for details. I think I have been very messy with using the Streams. Can you review for a good and better implementation with Streams? Any other improvements? ...
1
vote
0answers
29 views

Undirected graph implementation in java

Here is my code which implements a undirected graph in java. I'm fairly new to java(I come from C) and I am not sure if this is a good implementation. Here are a few things i worry about - Did I ...
3
votes
1answer
153 views

Guessing game in Java - Take 3

I already have two versions of this code reviewed (thanks @Bobby). They can be found here and here. The question is still the same. The goal is maintainability and following best practices. Jar....
3
votes
1answer
150 views

“Parking” challenge solution

This is the problem statement. I have submitted successfully a \$O(n^2)\$ solution and I would like to know if there is a way to improve the running time to, maybe, \$O(n \log n)\$. Having dropped ...
3
votes
1answer
54 views

Simple Wizard Goblin User Story Test Driven Development

I have written this to practice Test Driven Development. I would like to know if the process is right and how it could be improved. Problem Statement : A wizard can cast spell on goblin and make his ...
1
vote
2answers
63 views

Project Euler #7: What is the 10,001st prime number?

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? How can I make this more efficient and cleaner? ...
1
vote
1answer
18 views

Efficient text to binary conversion in Java

I wrote a Java FX application that translates binary to and from String and numbers in Java. Whenever the program is translating large amounts of text to binary it takes a very long time, and leaves ...
1
vote
0answers
14 views

Improving rendering of JOGL

I'm trying to use JOGL and Java to draw a hexagonal based game. I currently have it so that it displays correctly, however it seems to run poorly and needs optimization. Currently I create a glList ...
1
vote
0answers
46 views

Simple password verification before proceeding to a game [on hold]

I wrote this code a little while ago and ran it a bunch of times trying all possible combinations just to make sure it all works and it worked fine and no errors came up but now when I bring it up in ...
2
votes
2answers
49 views

Hi-Lo guessing game with numbers

I am new to Java in general, but wanted to get some input on the code for a CS class I am taking. It is a program that plays the Hi-Lo guessing game with numbers. A user may choose to quit mid-game ...
-3
votes
0answers
21 views

Storing more than one information into one Node in a singly linked list [on hold]

I'm trying to add several information into one Node in a singly linked list... How do I do that? After asking the user for several vehicle information: plateNo(String), vehicleType(String), ...
0
votes
0answers
43 views

Finding the output of series (a+2^i*b)

I just started programming. I have taken too much time to code for the problem in given image. I just want to know whether this code can be further optimized in Java for this problem: ...
3
votes
1answer
51 views

Guess how many are in the jar game in Java - Take 2

Original question can be found here I took the advice I got to heart, and re-wrote it. Once again I'd appreciate any advice as to how I can improve this using best practices. Jar.java ...
5
votes
1answer
34 views

Comparing algorithms for computing binomial coefficients in Java

I have these 3 different algorithms for computing binomial coefficients (I also had the 4th recursive one, yet I discarded it since it is super slow). The first uses the factorial formula, the second ...
2
votes
0answers
30 views

Easily add Accessibility to your app as an afterthought. Yes, as an afterthought

Accessible apps allow more users to use your app; however, it is usually an afterthought for developers, and it makes your XML layout files messy whether Accessibility was a forethought or ...
1
vote
1answer
65 views

Guess how many are in the jar game in Java

I'm reading up on java and have completed a fairly simple console game. I'm unsure on my own structure when considering maintainability, separation of concerns and best practices. Any tips or ...
2
votes
1answer
42 views

Count character replacements needed to make string a palindrome

Problem Count the number of character replacements necessary to convert an input String to a palindrome. Each character replacement must replace the given ...
4
votes
2answers
613 views

Project Euler #5

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 ...
0
votes
0answers
35 views

Custom Input split for unstructured data

I am planning to parse below file with Spark, so I have written a custom input split, I want the values from Hadoop to Spark as ...
1
vote
1answer
22 views

`Piece` class as part of implementation for the Tetris game

Here is my Piece class as part of implementation for the Tetris game. Critics of any kind and levels are very welcomed. If possible, I want my code to face the ...
10
votes
7answers
2k views

Java diamond with numbers

I have an assignment to code a method that will print values in a diamond pattern. For example, if the method is called like printNumberDiamond(2), then the results ...
-3
votes
1answer
61 views

Reading files from one location to another

Here I am trying to read files from one location to another using lambada expressions, so the method checkValues(...) returns a list of all files which are copied ...
4
votes
6answers
712 views

Project Euler #4: Largest palindrome product

How can I make my code for Project Euler #4 more efficient and cleaner? Project Euler #4: Largest palindrome product: A palindromic number reads the same both ways. The largest palindrome made ...
3
votes
1answer
80 views

Using a LinkedList type of adjacency list to create the word game: WordLadder

Goal The user puts in a starting word and an ending word. My code creates a ladder between these words of words that are different by one letter. Start: gain End: fire Output: gain gait wait wart ...
-1
votes
2answers
60 views

Java dog hierarchy

I am supposed to write a small java program. The program must contain 3 different kind of dogs. The dogs can bark and move, these methods can be represented just by System.out.println();. Some dogs ...
3
votes
1answer
64 views

Guess a number game with mines version 3

I'm still new to Java and learning programming, so my main goal is to learn to making good code, so I don't want to do anything complex until I fix all of my bad coding habits on smaller programs. So,...
9
votes
4answers
2k views

Binary difference checker

My code needs to take two ints and then check those ints to see if their binary representations have any differences. The ...
3
votes
0answers
43 views

Playing around with Vigenere and Caesar cipher - Java command line encryption program

I came along these two ciphers in my cryptography book and though I'd implement them just for fun. After that I went on developing a cipher based on these two that minimize the weakness of each cipher ...
0
votes
0answers
26 views

Android network api request

I often use a similar scheme work with api project. Maybe it can be made easier, or is there a standard approach? This class who create api request. ...
1
vote
1answer
37 views

Insertion Sort Implementation Using For And While Loop

Introduction I'm fairly new to programming (and Java) and I've actually never implemented Insertion Sort. I know that there's pseudo-code defined in the wikipedia article (linked above), but the ...
5
votes
2answers
59 views

Java controller to farm out concurrent tasks

I've recently given a coding interview on a Java concurrency task and unfortunately didn't get the job. The worst part is I've given my best but now I'm not even sure where went wrong. Can anyone ...
3
votes
1answer
24 views

TLE on SPOJ for Prime Generator (PRIME1)

The objective is to find all primes between two given numbers. It is specified that the two numbers are \$\le\$ 1 billion and the difference between the two numbers is ~100,000. We are to repeat the ...
2
votes
2answers
80 views

Fibonacci sequence methods

Decided to get a little JDK 8 practice in today, so I built two methods to print out the golden ratio, one uses the Stream API the other does not. Wanted to request general feedback on how well I ...
4
votes
2answers
54 views

Generic Skip List Implementation in Java

I am interested in implementing advanced data structures. One of them that tickled my fancy is the Skip List. My implementation is shown below: The SkipList node ...
5
votes
4answers
111 views

Beginner Rock, Paper, Scissors in Java

I was curious on what, if anything, I could be doing better. I have been spending the last few days working with Java and learning some basics and wanted to try this challenge and making it two ...
1
vote
0answers
25 views

Spring controller for login using Facebook or email

I've got a spring controller class which handles the user logins. I've got two endpoints: /user/facebook /user/email You ...
5
votes
1answer
130 views

Broken keyboard challenge

Inspired by Reddit r/dailyprogrammer Help! My keyboard is broken, only a few keys work any more. If I tell you what keys work, can you tell me what words I can write? The program works fine, ...
3
votes
1answer
70 views

An app that uses the quadratic formula to solve ax^2+bx+c=0 so long that the answers aren't imaginary

I'm a beginner to Java and Android programming, and I wrote this app in order to get some practice. It works, but it's most likely not as good or efficient as it could be, since I'm new. I'm hoping to ...
3
votes
1answer
40 views

My first build.gradle for a 3D space graphics program

I'm writing a 3D space graphics program and I just changed the build system to using gradle. This is my first gradle project. It works but I'm sure there is room for improvement. ...
1
vote
1answer
38 views

Printing the power set of a given set of elements

Input: Set of elements (String) Output: Printing the elements of the power set of the given set ...
4
votes
1answer
53 views

Card payment strategies

In my project, I have 3 payment mode. Via Manually Entered , Card Swipe, and cash. I have 2 fragments named RecordCardManuallyFragment and ...
8
votes
1answer
641 views

Cheapest hotel finder

Please help me make this code more object oriented. I also want to use a few more classes and separate the input processing code to another class. Question: A hotel chain operating in Goa wishes ...
3
votes
0answers
34 views

JavaFX Scene Video Capture Utility

2 days ago as I was working on my game I decided I wanted to include some sort of a video showing sneak peaks of the themes and tutorials and such. I then decided to check how to record my scene or ...
1
vote
0answers
42 views

An event bus implementation for java

I have implemented an event bus library for Java - JBus. Anybody please care to review my code? It is an open source project and link is provided above. Usage Define events: ...
2
votes
2answers
138 views

Thread synchronization wait/notify

I need to run several identical threads. All threads must wait to do their job, until all threads are running (alive). I use wait/notify to synchronize: when a thread is created it waits until it ...
0
votes
0answers
18 views

Declare Parcelable KEY String constant INSIDE Parcelable class? [closed]

I would like to know two things: How others hold String constant used for Parcelable key Idea or opinions about declaring <...
-4
votes
0answers
12 views

How to increase the speed of the ball every time i click on it? [closed]

So this is the code of the ball I've written. I want to increase the speed of the ball every time i click it. Please help me to do it. ...
0
votes
0answers
29 views

LinkedList of Nodes at each level - optimalization

That's already known problem: to return an array of linked lists that contain values of elements at each level. Eg for tree with depth n there should be n linked lists. I wrote the solution: ...
3
votes
4answers
119 views

Remove adjacent duplicate characters

Introduction This problem is essentially equivalent to this HackerRank problem. The task is to remove all duplicate characters that are adjacent to each other in a given ...
5
votes
4answers
515 views

Project Euler 3: Largest prime factor

How can I improve my code, make it more efficient, and are there any tips you have? Project Euler 3: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the ...