Questions tagged [java]

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.

Filter by
Sorted by
Tagged with
2
votes
1answer
43 views

Merge in list from another list that are not present in the former list

The two list have different structure. The list originalPgs is a list of PGRatingConfig and has this structure: ...
1
vote
1answer
46 views

Scoring system for events

A newbie here. I have done this assignment that my university gave. Requirements Participants may enter the tournament as individuals or as part of a team** It is expected that will be 4 teams each ...
0
votes
0answers
15 views

Chain the same Runnable using Handler in Android

Which approach to creating repeating Runnables is better? ...
2
votes
1answer
45 views

Leetcode 1584. How to make my Kruskal&Union Find algorithm faster?

The question was on Leetcode 1584. Min Cost to Connect All Points. My answer to this question is: ...
18
votes
7answers
5k views

The car plate problem: generate from AAA0001 to ZZZ9999 skipping the 0000

I was given the problem (called "car plate problem") to write all the values that go from AAA0001 to ZZZ9999 with the following premises: Create all the possibilities from AAA0001 to ...
3
votes
0answers
38 views

Text-based Monopoly in Java

I am currently creating a Java console program for a text-based Monopoly game as a personal project. Since this is my first project that I have worked on, I would like to know what kind of object ...
0
votes
0answers
24 views

Java dependency injection and hiding details of methods in “Database”-class

I recently posted a bunch of code of my to-do list application and after getting some very helpful and good suggestions on how to improve, I took a shot at it! Here's a link to the former post I made -...
2
votes
0answers
36 views

Hungarian algorithm for optimal assignment

The assignment problem is about assigning tasks to workers, where each pair (worker, task) has a cost. The Hungarian algorithm builds an optimal solution for this problem. It has two variants, ...
0
votes
0answers
17 views

Faster, indexed, heuristic doubly-linked list data structure in Java: unit tests

Here I have the unit tests for the indexed doubly-linked list. It goes like this: ...
0
votes
0answers
20 views

Faster, indexed, heuristic doubly-linked list data structure in Java: benchmark

I have this benchmark program for my indexed linked list. It looks like this: com.github.coderodde.util.benchmark.LinkedListBenchmarkRunner ...
0
votes
0answers
47 views

Faster, indexed, heuristic doubly-linked list data structure in Java: implementation

I have this doubly-linked list data structure that runs all the single-element operations in \$\Theta(\sqrt{n})\$ time (refer to this post and this repository). (See this for benchmarks.) (See this ...
-5
votes
0answers
54 views

How i can improv this [closed]

I made this, basically the user can toggle options to be able to see them or not in the application. There are parts like SEARCH & MAP that only change the value in the map and nothing else, would ...
6
votes
1answer
90 views

Create tweet threads from String in Java

I recently got this question in an exam, this is how I implemented, it is working fine. However, I would like to know if the code can be improved, as I think it for sure needs to be improved. The ...
0
votes
1answer
68 views

Binary search to find the closest element

I wrote a binary search to find the closest element to x in an array. How can show the correctness of the algorithm for any cases? Because it handles with floating points and variable length arrays, ...
1
vote
2answers
44 views

How to take out attribute from two ArrayList of object which have different match in optimize way

I have two ArrayLists of objects and the after comparison I am taking out the value which has a difference based on the attribute. So in my condition when the ...
2
votes
1answer
126 views

A to-do list application written with Java

This is the first project I have ever undertaken and now that I've gotten it to a point I feel comfortable with, I would love to get some review and tips for any improvement on it! I am especially ...
4
votes
2answers
61 views

Enigma Implementation by JAVA newbie

I want to learn Java, so I ported a C# Enigma implementation of mine. It got UnitTests and is running. I'm looking for a review, telling me, where I don't know best practices, where I break naming ...
1
vote
1answer
45 views

Is Array Separable To Two List

The aim of the implementation is divide an array to two sub array which the total of the every sub array should be equal. If Array is dividable then method return ...
5
votes
2answers
77 views

Conway's game of life as Java OO with underlaying array

Well, there are many game of life's already, but after posting an answer on it in C#, I thought I might as well check if I did any better and if there is anything new to learn - there always is. ...
2
votes
2answers
103 views

Program that encrypts and decrypts messages and texts

Overview This is a program that encrypts and decrypts messages and texts using two simple algorithms. Please note, the algorithms used in this project are not suitable for production use. I used them ...
1
vote
0answers
57 views

I'm making a 2D game engine with JAVA Eclipse 2021-06 but it is underperforming in FPS for my NVidia RTX 3070

This is my first Stack Exchange question, so please bare with me. I'm following this tutorial on youtube by The Cherno, Im only up to episode 16 and I have done this on another laptop before and had ...
-1
votes
1answer
33 views

Find Passable Lanes in Rows and Columns

I have implemented the following question and looking forward for the reviews. Question Explanation : We have a two-dimensional board game involving snakes. The board has two types of squares on it: +...
2
votes
0answers
36 views

Giffler Thompson Algorithm for decoding individuals of a Genetic Algorithm

First of all: Hi, my name is Henrik and I am a mechanical engineer, who loves to code in his free time. To get better in programming I wrote a genetic algorithm compined with a list planning algorithm ...
2
votes
1answer
53 views

Best way of cleaning up resources with CompletableFuture [closed]

Edit: cross-posted this question on Stackoverflow. Suppose I have a function that takes a FileInputStream, performs some operation using the file data in the ...
0
votes
0answers
22 views

What is the right way to write a native query in Spring JPA?

I've been looking at the way the native queries are written in my project and it just seems overengineered in my perspective. Writing a native query should be simple. Can someone suggest the right/...
1
vote
1answer
28 views

Java generic 3-median quicksort

My generic 3 median quicksort: ...
0
votes
2answers
48 views

Insertion Sort code in Java

I have written basic insertion sort in java and I would request you to please spend some time on this code and give me your review of code. Is there anything I could have improved: ...
0
votes
0answers
33 views

RabbitMQ multiple queues and process the message

I'm looking for advice on how to improve my code or find some potential bugs. I have a Java app which listen to multiple RabbitMQ queues and process the messages. In the my case I have 5 queues. I ...
0
votes
0answers
86 views

If maze has path

I have applied a DFS solution for to check finding path if exist from beginning point to the end point. OA: Given 2d array, check if there is path from one beginning point to given endpoint in the ...
-2
votes
1answer
78 views

Thread-safe collection to store Member objects [closed]

This is poorly written Java code, intended to implement a thread-safe collection to store Member objects and failing at doing so. ...
2
votes
1answer
64 views

Efficient usage of Java Stream API to convert one object to another

I have a model of Author which has books, awards and pricing as shown below (Not showing getters and setter just to avoid verbosity) Author: Has books and prices for the books ...
3
votes
2answers
653 views

Make Array Consecutive

Ratiorg got statues of different sizes as a present from CodeMaster for his birthday, each statue having an non-negative integer size. Since he likes to make things perfect, he wants to arrange them ...
1
vote
0answers
35 views

Extract series of XML elements' values into an array

This code needs to extract data from in XML file. Specifically it needs to iterate over it, looking for a node called CHARGE_CODES that repeats over and over and ...
3
votes
2answers
72 views

Determine number properties

I am making a program about numbers. The user will enter a number and will get its properties. Program objectives Welcome users; Display the instructions; Ask for a request; If a user enters zero, ...
4
votes
1answer
130 views

A different approach to string pattern matching algorithm

Although there exists the most efficient "Knuth-Morris-Pratt" algorithm of string pattern matching. I tried to achieve the same result with a different approach. But I am not sure about it's ...
1
vote
2answers
79 views

Leetcode kth largest element without using heaps

I was working on kth largest element problem on leetcode Question Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in ...
2
votes
1answer
61 views

Correct synchronization of reads and writes to ConcurrentHashMap and ConcurrentLinkedQueue

I am writing a web application (Servlets, JDBC, no Spring - for learning purposes) that accepts orders from customers, while registered couriers can choose which one of these orders they want to ...
0
votes
1answer
68 views

Interpreting abbreviations for days of the week such that they are consecutive days

The code below works, but it seems it could be done better. Is there a better/more efficient way to do this? Given: All days off ("relief days") will be consecutive. Relief days will be ...
4
votes
2answers
78 views

Game Of Life program in Java

I wrote a program for Conway's Game Of Life in Java. Are there any improvements I could make? main class: ...
3
votes
3answers
133 views

Java OOP Calculator (no GUI)

i have created an object orientated Calculator without GUI. i have provided only the most important parts of the code. I want to add another review question for those parts (especially: ...
1
vote
1answer
35 views

Daily coding problem: Job scheduler invoking a function after specific time

This is a problem from Daily Coding Problem. I have implemented it in Java. For a function f I have used Runnable interface. ...
0
votes
1answer
71 views

Given a 2d matrix with chars find the target string

I am looking for a simpler implementation of the following question. Could it get better? I am expecting the new solution via DFS again. Thanks. OA: Given a 2d matrix with chars and a target string. ...
3
votes
1answer
88 views

Google Foobar - “Distract the Trainers”

QUESTION: You will set up simultaneous thumb wrestling matches. In each match, two trainers will pair off to thumb wrestle. The trainer with fewer bananas will bet all their bananas, and the other ...
0
votes
1answer
54 views

Finding nodes with 0 or 1 parents - DFS or BFS

I completed the following question but it seems a lot of space complexity. Do you think is there a way to complete it with graph search or so? Thanks for the comments. Suppose we have some input data ...
3
votes
0answers
75 views

screen recording application

I'm developing a screen recording application using java. I've modified code from https://dzone.com/articles/screen-record-play-using-java where all the external jars required for this application are ...
1
vote
1answer
64 views

StringModifier - Reverses a string and returns information about it

I have been coding in Java for about a month now and I'm seeking advice for my program on things I can improve. This project was mainly made for me to incorporate all the new things I learned and ...
1
vote
3answers
100 views

Generating a number of students and assigning them

...
1
vote
4answers
690 views

How to rewrite if.. else statements in a more elegant way

I created this short method: ...
1
vote
1answer
59 views

AgeCalculator - Calculates your current age using your birth date

I have been learning Java for approximately 3 weeks now and made 2 posts on code review. Learned quite a lot from people and learned a lot of Java at the same time as well. I made this Age Calculator ...
6
votes
1answer
1k views

friend locator app

I was rejected after a tech screening for the following code. I mainly struggled to make the code 'production ready'. I was running out of time so I did not create a class for testing. How could I ...

1
2 3 4 5
212