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 bytecode and run in a virtual machine (JVM) enabling a "write once, run anywhere" (WORA) methodology.

learn more… | top users | synonyms (2)

2
votes
0answers
34 views

Travelling salesman implementation

I am working on an android application the travelling salesperson problem (a list of cities and the distances between each pair of cities, counting shortest possible route that visits each city ...
1
vote
1answer
31 views

Improvements for ugly reflection

I have a project that uses a library to save serialized objects in items and loads them again, when needed. To do the de-/serialization, this library uses Gson. Due to how Gson works and how the ...
3
votes
2answers
72 views

Foobar Fuel Injection Perfection efficiency

I was writing this code and was using the BigInteger class because it needs to work with numbers up to 309 digits long, however it takes too long to run with numbers that are too big. I was hoping to ...
4
votes
3answers
89 views

Calculation of the money to be paid back to the employer

I'm a beginner developer and I wrote a simple program. How could be the code improved to meet best practices of the development? I mean if the names of classes or variables are enough self-explaining ...
5
votes
0answers
29 views

Spring JWT authentication using cookies

I'm working on a experimental code which allows users to authorize using JWT's jjwt library. Here's what I have done so far on authentication and authorization flow....
5
votes
2answers
484 views

Object oriented design for access control

Problem Statement: Design an employee swap in swap out system. The system will have a machine which records the swap in and swap out. The user can also login in a portal where he can check his ...
1
vote
0answers
46 views

Generating all permutations of a given array

I have written this Java snippet to generate all permutations of a given Array of a HashMap. Can this be done in a better way? ...
-2
votes
0answers
17 views

fxml switch one window to another window [on hold]

from the image view button is there if button press should open new window and my code from controller is This is code is from main controller to call other fxml/load fxml private Button ...
3
votes
1answer
32 views

ServiceLocator for easy and central access to replaceable parts

For a bigger project of mine, I needed a simple and extensible solution for easy access to replaceable Parts. This example will show the usage: Define an Interface, describing the replaceable part ...
3
votes
1answer
48 views

Simple Java Swing calculator for addition and subtraction

I have built a simple calculator using Swing that can perform two operations, addition and subtraction. I would like to extend the operations and add more functionality, such as multiply, divide, ...
1
vote
0answers
44 views

Continue or Terminate after catching Interrupted Exception? [on hold]

I have a while ( true ) loop that should run for the duration of the program. If it is interrupted or terminates, the program should also terminate. In that loop, I occasionally call Thread.sleep () ...
1
vote
0answers
42 views

check for null before or after casting

I have a list of BasicDBObject that I fetch from my database. This is basically a JSON document converted into a java Object. Let's assume that we have a ...
2
votes
1answer
67 views

Simple calculator about keybinding

This is code for a simple calculator. Can someone review it, so I can know if there is something wrong? I also want to know if I can link a keybinding to a JButton so I don't have to write an ...
2
votes
1answer
41 views

Spring MVC verification email sending service

I have a @Service to send verification emails. Here is the code of the service: ...
-1
votes
0answers
26 views

Method that produces a staircase [on hold]

I was tasked with writing a method that would produce a staircase like so: I managed to do this using a 2D array but was thinking of ways I could improve the runtime of my code and or other ...
2
votes
3answers
63 views

Method that compares the scores of two players

I tackled this problem today and was wondering how I could possibly improve this code. The objective of the method is to return an array with the respective scores of each player. The method takes ...
5
votes
1answer
41 views

Swing “Number Guesser” program

I have made a UI that guesses the number that the user is thinking of(0 - 100), and I am wondering if it can be improved(I guess this is simple AI). I tried to shorten it as best I could, but it still ...
0
votes
0answers
14 views

Android Canvas - Draw a line graph with a gradient whose color depends on the y value

I'm looking mostly for feedback on a solution of mine. I want to create a pretty line graph where the color of the line is dependent on the Y value, and a change in color at ...
0
votes
1answer
25 views

CodeForces Freshman exercise

There are 60 submissions from me to the very first beginner-freshman exercise at codeforces.com. Problem: 100985A - MaratonIME helps Pablito I don't pass the tests because of Time limit exceeded (tle)...
1
vote
0answers
17 views

Download the contents of an HttpURLConnection while generating metadata

Working on a web crawler (again), except now I've had a lot more time to hone my skills. The largest bottleneck in my program, as is to be expected, is the actual downloading of the data, so I'd love ...
2
votes
3answers
95 views

Number-guessing game in Java

I created a java number guessing game. I used some of the same code twice. I would like to know how to further simplify it if possible (I am a java beginner). ...
2
votes
0answers
25 views

RxJava2 custom Observable

I'm trying to understand how to bridge receiver-based events to the Reactive world. I asked a question on SO and was pointed to a different approach. The author of that answer (David Karnok) is ...
2
votes
2answers
97 views

Number of prime numbers in a given range

I've written a method that should return the numbers of prime numbers in a given range: ...
-2
votes
0answers
24 views

chess problem (check the check) [on hold]

I am trying to solve the problem from http://www.programming-challenges.com/pg.php?page=downloadproblem&probid=110107&format=html But system shows me - wrong answer. I have checked a lot of ...
3
votes
0answers
25 views

oEmbed provider servlet to handle four media types

I would like to add oEmbed tags to my site (I'm the oEmbed api provider). My api should respond the results based on the file type. oEmbed Types has Photo Video Link Rich My response to photo ...
-2
votes
0answers
16 views

Error when inserting data into a database using Spring and Oracle [closed]

I am a coding newbie, I have been learning spring and I get this error every time. I have tried googling and checking Spring and Java forums, but, I have been unable to find a solution that fits. This ...
2
votes
1answer
36 views

Tic Tac Toe in Android

I made my first Tic Tac Toe game on Android and I'm looking for a way to simplify, make the code more flexible and remove the hardcoded code. I managed to do this game by looking at different ...
-1
votes
0answers
31 views

Program Architecture for a Music Player [closed]

I am refactoring the code for a music player I wrote in Java/JavaFX. I have a few key objects which are accessed throughout the program by various other classes. I think there will be four or five ...
0
votes
1answer
30 views
4
votes
1answer
100 views

Remove duplicate chars from String

I have retackled this problem using the help I received from here: Remove duplications from a Java String but this time using a LinkedHashSet since previosuly I was ...
-2
votes
0answers
24 views

Java Input form [closed]

I need help doing my assignment I was supposed to write a java program where a user inputs his name, age and gender.I tried this code but it did not output the way I wanted. This is my code: ...
3
votes
1answer
75 views

I finally solved the Birthday Problem using Java

I like to put ideas and mathematics into code whenever I am interested in the subject. Ever since I was introduced to The Birthday Problem I wanted to throw it into a Java program. I started writing ...
1
vote
1answer
24 views

Iterative quicksort in Java

I have this quicksort implementation that relies on heap memory instead of actual stack. It uses two integer stacks for keeping track what subranges are yet to be sorted. When a partition routine is ...
0
votes
0answers
11 views

Taking input from DB using isel function and assigning them to different var to use them but because there is a pattern so i think,It could be shorten

Here is my code, observe what I'm trying is, to shorten this code, but due to the slight difference in name of the variables, I'm stuck. Though the pattern is same. Please help me out. ...
3
votes
1answer
72 views

Reading values from a file and assigning to another class

I'm assigning values to an object by passing it to another class. Basically, I'm reading values from a file and assigning it by passing it to another class. This is the POJO class for the details in ...
1
vote
1answer
47 views

Overriding equals and hashCode vs providing only Single Instance on immutable Objects

Let's say we have a class SomeInt which holds just one single final int value: ...
3
votes
5answers
128 views

Get the last two digits of a string

What would be the most performant way to get the last 2 digits of a string? For example: getLastTwoDigits("a1b2cd3e4ghi5jk") must return ...
3
votes
0answers
41 views

Structure of a serial port reading program

I am writing a serial port communication app. And I thought I could get some feedback about the general structure of the program. If I am doing MVC correct, etc. Since this is a "large" program I ...
4
votes
1answer
49 views

Bouncy castle 128bit AES/CBC/PKCS7 in java

I have been trying to do some encryption-decryption using bouncy castle and with the available docs and samples on the internet I have managed to prepare the below. Though this works without throwing ...
1
vote
1answer
19 views

is it good practice to use relative path in xpath more than once [closed]

I am using Selenium Webdriver-Java to automate a web application. Suppose the html is somewhat like below: ...
0
votes
2answers
83 views

Remove duplications from a Java String

today I tackled this coding challenge: Remove duplications from string. I was thinking of either using a Hashmap or a Set but realized that a set might have a longer run time since the way it ...
1
vote
1answer
43 views

Is it a valid use case of using java.util.MissingResourceException?

I have a factory method that returns an Object based on a argument passed to it : ...
-2
votes
0answers
46 views

Google Foobar Level 4 Running With Bunnies [closed]

This is the Problem i am having problem with. I have written the code for it. but it is arrayoutofbound exeception for some unknown input. You and your rescued ...
-3
votes
0answers
22 views

Choose the right collection interface [closed]

In an institute following information is maintained about the students Student Class ...
5
votes
1answer
66 views

Parse and format date

I have the following code for taking a date in the form of a string yyyy-MM-dd HH:mm:ss (UTC timezone) and turning it into ...
5
votes
1answer
80 views

Wrap string at certain delimiters

The method receives an unformatted string and it needs to put line breaks after ';' or before 'i)' and 'i.', where i - integer. If received a string like '; 1)', then it should add only one line ...
-1
votes
0answers
24 views

Member variable in generic abstract base class? [closed]

I have a hierarchical data model and am trying to implement their CRUD operations in my Web Application. Currently I have code inheritance for CRUD operations of my entities (resources) as follows: ...
-1
votes
0answers
18 views

Digital signing XML message using Java [closed]

We have an unsupported application at my place of work which digitally signs XML messages using a certificate from a keystore that we want to replace. Im attempting to write a replacement application ...
2
votes
2answers
50 views

TapeEquilibrium Java Implementation

A non-empty zero-indexed array A consisting of N integers is given. Array A represents ...
-2
votes
2answers
84 views

Java8: clean method code

Is there any way to clean code with Optional or something else? ...