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
0 votes
1 answer
33 views

Creating Worst-Case Scenario for QuickSort using Middle Pivot in Java

I've implemented a solution to generate the worst-case scenario for QuickSort using the middle pivot strategy in Java. The goal is to rearrange an input array to produce the worst performance during ...
Lydia Yuan's user avatar
1 vote
1 answer
61 views

FieldInspector: an API for deep object comparison and null checking

Here's my FieldInspector. It compares objects by field values and performs deep null checking. What do you think? It works, but I'm not happy with how it looks. I ...
Sergey's user avatar
  • 381
1 vote
1 answer
72 views

Positioning boxes in a box with backtracking in Java

A large cube-shaped box has the dimensions 5x5x5. This box is to be completely filled with smaller boxes. Possible candidates are: ...
Tobias Grothe's user avatar
-2 votes
1 answer
49 views

Handling exceptions of FileInputStream and XSSFWorkbook

Can you tear my code apart with code review comments? Below is a simple method which reads an XLSX file and does some stuff with it. I use FileInputStream and ...
AutoTester999's user avatar
1 vote
2 answers
87 views

Simple service that wraps access to json file

I'm wondering if this is the best way to write the Java code I have written. It works, but looks overly verbose, is it possible to rewrite any of the code to make it more concise? Please ignore the ...
Professor of programming's user avatar
0 votes
0 answers
51 views

Sequentially bidirectional find the indexes of an element into a collection (second thought)

Embodying the helpful tips from the “Sequentially find the indexes of an element into a collection” previous code review resulted in extending the implementation to bidirectional index lookup, that is ...
user avatar
4 votes
2 answers
127 views

Print the three most occurring chars in Java using streams

The three characters that occurs most in a given string should be printed by using streams/lambdas (functional programming). The order of characters that occur equally often should be preserved. My ...
Tobias Grothe's user avatar
2 votes
1 answer
80 views

Sequentially find the indexes of an element into a collection

Util class to find into a collection the indexes of a given element with multiple occurrences from the first index or relative to a given index. ...
user avatar
0 votes
0 answers
25 views

Determine top t values with few calls to order(), a given procedure to order k values

Trying to write a decent answer to Most efficient way to get the largest 3 elements of an array using no comparisons but a procedure for ordering 5 elements descendantly, I came up with something ugly....
greybeard's user avatar
  • 6,094
2 votes
2 answers
107 views

Adhering to Object-Oriented Principles in Fruits and Vegetables Scale Program

I've been working on a project related to a fruit and vegetable scale program for about a month, and I'm relatively new to programming. In this project, I'm trying to adhere to object-oriented ...
Kerem Tazedal's user avatar
1 vote
3 answers
86 views

Another ATMs cash-out (denomination) algorithm in Java

Related to this question and this answer, I would like to have a second review from you on a modified version. The problem I tried to solve Some kind of "Minimum count of numbers required from ...
Tobias Grothe's user avatar
2 votes
2 answers
285 views

Another cash machine with special bill values in Java

Task: An ATM dispenses banknotes with the following values/denominations: {5, 30, 35, 40, 150, 200}. The user should be able to repeatedly enter an amount divisible by 5 without leaving a remainder. ...
Tobias Grothe's user avatar
0 votes
0 answers
37 views

Is this how you do Spring Cloud Gateway?

I'm new to Spring's reactive Gateway. Here's the code that other collaborator and I wrote (the enum is one of my ideas): ...
Sergey's user avatar
  • 381
0 votes
1 answer
34 views

Implementing an improved merge sort that uses insertion sort, with "levels" - Would this work correctly?

We were asked to improve the merge sort algorithm by introducing insertion sort to the code. We have been tasked with doing this by utilising a "levels" logic. Here is the exact description ...
Preatorius's user avatar
1 vote
1 answer
47 views

"2048" game in JavaFX

I wrote my first code in Java and I need constructive criticism and code review. This is an implementation of the well-known "2048" sliding-blocks game. ...
hathor's user avatar
  • 11
4 votes
1 answer
1k views

Determine if it is EU summer time in Java

I wanted to write a utility method for learning purposes to determine if a given date (year, month and day) falls within EU summer time or not, without using any of the Java library methods. Is here ...
Tobias Grothe's user avatar
1 vote
1 answer
132 views

Interview task model implementation(Event Source Java)

I've got a task to implement simple event source and i did: project Events structure ...
verbedt's user avatar
  • 11
0 votes
1 answer
110 views

About self validated Java POJOs

I am currently experimenting with self validating Java beans in order to avoid the creation of objects with invalid states, while keeping the validation knowledge inside the bean. The goals I have in ...
silver_mx's user avatar
  • 109
3 votes
2 answers
260 views

Reduce time complexity to process sub-arrays

For a given integer array of size n, find all possible sub arrays of size k which range from 1 to n. Now find the common item which is also a minimum in all sub-arrays of size k, if no common item is ...
technotigr's user avatar
1 vote
1 answer
84 views

Shrink an array of double elements (uniformly)

Is there a way to avoid the first loop in the method shrink? (if and while...) The utility ...
Tobias Grothe's user avatar
2 votes
1 answer
40 views

Program using java.io that shows the content of a text file and every three lines the program stop reading, waiting to press Enter

I am doing a program in Java your text using java.io that shows the content of a text file and every three lines the program stop reading, waiting to press Enter. I dont know so much about programming,...
polencr_ensayoerror's user avatar
4 votes
2 answers
162 views

Improvements for Java Code of a Fruit and Vegetable Management Application

I have developed a Java application as per a specific assignment, which includes features for adding, searching, and removing fruit and vegetable products. I would like a review of my code in terms of ...
Kerem Tazedal's user avatar
5 votes
1 answer
114 views

One or more planets to line up with the earth a certain amount of times

I have attempted the below question, however my solution is too slow (i.e. It does not fit the 2 second time constrain for java). How can the solution be optimised? While at IOI 2020 in Singapore, ...
Zareef Akoodie's user avatar
1 vote
2 answers
112 views

Thread-safe coordinate holder

I have been given a task to create a thread-safe RobotCluster class. The idea is that there's a set of robots operating on multiple threads and they each submit the ...
Bula's user avatar
  • 369
0 votes
2 answers
76 views

Verification job with multiple type of batch verifiers

I have a use case where a verification batch job (non-generic) verifies domains based on its input e.g domain_type, batch_pointer etc. The verification handles it based on the domain type which uses ...
user3239193's user avatar
1 vote
1 answer
117 views

Business logic verification template

I have a use case of template design pattern with generics as mentioned below. I have AbstractVerificationHandler that provides template for verification business ...
user3239193's user avatar
3 votes
2 answers
164 views

Add offset to all filenames

From all the files in a directory, the method shiftFilenamesOffset is to increment the numeric part (int) of the alphanumeric filename by offset each time, and ...
Tobias Grothe's user avatar
1 vote
1 answer
73 views

Performance of this BCrypt lossless compressor

The following code compresses a 60-byte BCrypt MCF into 40 bytes. Does anyone see room for performance or other optimizations? For example, I should replace Guava's ...
Oliver's user avatar
  • 73
1 vote
1 answer
131 views

Find character at given index in a sorted sub strings [closed]

For a given string say dbac the possible substrings are [d,db,dba,dbac,b,ba,bac,a,ac,c]. Sort them and concatenate to a string: ...
technotigr's user avatar
2 votes
2 answers
165 views

Java Tic-Tac-Toe Game Implementation - Seeking Feedback and Best Practices

I have recently developed a Java program for a simple Tic-Tac-Toe game and would like to request a code review to improve its quality and learn from experienced developers. Below is the code for my ...
drunk mado's user avatar
0 votes
0 answers
61 views

A Java program interfacing with Gnuplot for generating triangle wave plots

Intro I have this repository. Given this command ...
coderodde's user avatar
  • 27k
1 vote
1 answer
82 views

Mapping composition in Java - v2

This post is the continuation of Mapping composition in Java. This time, I: Disallowed the null values as the range value. Simplified the ...
coderodde's user avatar
  • 27k
1 vote
2 answers
50 views

Spring Boot REST API for moving toy robot in 5*5 grid [closed]

I have designed and coded REST APIs to move the toy robot in 5*5 grid. Please let me know any feedback on improvements, etc Complete Code here: https://github.com/pkkht/RobotRESTApp ...
Hariharan's user avatar
0 votes
1 answer
148 views

Spring Boot Azure Service Bus Listener

I would greatly appreciate your feedback and review of our Spring Boot Azure Service Bus listener implementation. Your insights and suggestions will help us ensure its efficiency and reliability. ...
Siyamcela Nxuseka's user avatar
2 votes
2 answers
129 views

Counting duplicate elements in two sorted arrays

I've been working on an assignment that involves optimizing a duplicate finding algorithm for sorted arrays, and I'd like to get your thoughts on the implementation. Here's the code I've come up with: ...
Bryan C's user avatar
  • 21
0 votes
0 answers
131 views

Chain of Responsibility in the game of Hangman

I tried to do the Hangman Refactoring Kata for the piece of code over here - https://www.youtube.com/watch?v=-0MeoFTj6DU This is how the initial code looks like after first set of refactorings (i.e. ...
yadav_vi's user avatar
  • 486
0 votes
1 answer
55 views

DDD Aggregate for seat booking in cinema - is my model correct?

I created a DDD aggregate for booking seats in cinema. Is it corect or it should be model in other way? Business rules: 1.Seat can be booked at least 1h before screening 2.Screening can has only 1 ...
Nofenak's user avatar
1 vote
1 answer
101 views

blog RESTFUL api with posts and comments

I built RESTFUL api for a blog using java and spring boot(without a frontend). What it does the code manages all the http methods on a post inside the blog and comments on that post. the post consists ...
Guy's user avatar
  • 307
2 votes
2 answers
122 views

Mapping composition in Java

(See also the continuation of this post.) This time, I have a mapping type: com.github.coderodde.mapping.Mapping.java: ...
coderodde's user avatar
  • 27k
4 votes
1 answer
68 views

Beat Box: an app for making, playing, saving, and loading beat patterns

I was reading Head First Java. The book featured a project called BeatBox that allowed you to make, play, save, and load beat patterns using Java's Sequencer API ...
Sergey's user avatar
  • 381
2 votes
1 answer
79 views

Non-recursive topological ordering, starting from given nodes, for Guava graphs

This method returns the topological ordering of a Guava graph starting from a given set of nodes. It's from my personal project github.com/jbduncan/guava-graph-utils, where I'm exploring utilities for ...
jbduncan's user avatar
  • 141
2 votes
1 answer
50 views

Finance Manager with Embedded Database

I made an CRUD application in Java with JavaFX, H2 Embedded Database and Maven. Can you review my code quickly? Is it well written? What should I improve on it? I don't know if my code is written ...
Damian's user avatar
  • 21
0 votes
0 answers
32 views

A JavaFX program to find out the mouse refresh rate v3

(This post is the continuation of A JavaFX program to find out the mouse refresh rate v2.) After taking @J_H's suggestions into account, I ended up here: ...
coderodde's user avatar
  • 27k
2 votes
1 answer
52 views

A JavaFX program to find out the mouse refresh rate v2

(See the continuation of this post in A JavaFX program to find out the mouse refresh rate v3.) (This post is a continuation of A JavaFX program to find out the mouse refresh rate.) After adopting the ...
coderodde's user avatar
  • 27k
-1 votes
1 answer
74 views

is my code protected against SQL injections?

im using spring boot and CrudRepository for my queries, the project is about posting content on a blog, so I have a post record with id, creator name, post name, the content itself likes and dislikes: ...
Guy's user avatar
  • 307
3 votes
0 answers
29 views

FlashCard app using javax.swing

I made a simple flash card app. The general idea is from Head First Java, but it's one app instead of two (for both making cards and playing them) and the implementation is different. What do you ...
Sergey's user avatar
  • 381
1 vote
1 answer
72 views

A JavaFX program to find out the mouse refresh rate

(See the next version here.) Intro I have this tiny JavaFX program that shows a 800x600 pixel canvas. You are supposed to drag the mouse within the canvas. When you are done dragging, the program will ...
coderodde's user avatar
  • 27k
2 votes
2 answers
221 views

Distributed lock system using AWS S3

I need a distributed lock system for a service I'm writing. (There can be multiple instances of this service running at a time, and I need to make sure that only one instance does a particular cron ...
threed's user avatar
  • 161
1 vote
1 answer
76 views

Implement saga pattern with Kafka

There are very few example on how to implement saga pattern with Kafka so I tried to come up with my own implementation choreography saga pattern using Kafka. I need to implement outbox pattern as ...
Kazul Haram 's user avatar
5 votes
2 answers
183 views

Simple vocabulary trainer based on flashcards

Motivation When I was young, I had to learn english in school and I was really bad. My father told me to write words on little cards, with a word on the one side and its foreign counterpart on the ...
Dexter Thorn's user avatar
  • 2,154

1
2 3 4 5
217