As of May 31, 2023, we have updated our Code of Conduct.

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
-1 votes
0 answers
15 views

Sharing a global enum accross 15 nano service independently deployed

I have a mono repo with multiple nano services integrated with Kafka. The system data vesel is JsonMessage. This Json message is exchanged via these nano services. Same keys are used as element in ...
Alexander Petrov's user avatar
-2 votes
2 answers
50 views

How to refactor "long" if statment in lexer? [closed]

I have a Tokenizer doing lexer thing. It is used like String line = "class Main {" ...
codeDog's user avatar
3 votes
3 answers
430 views

BigNumber/BigFraction implementation in Java

I have created a BigFraction alternative to BigInteger and BigDecimal. Name for this class is not quite hammered down yet. I ...
davidalayachew's user avatar
1 vote
1 answer
28 views

Rate-limited thread scheduler in Java

Background: I'm planning to call different endpoints of a website's API quickly, but the usage policy implies that I may only make five calls in a second. I can't rely on the calls taking 200 ms on ...
mindoverflow's user avatar
0 votes
0 answers
50 views
+100

Spring Boot Account API with React Frontend and Identicon Integration

I have recently been exploring React and Spring Boot, and I would greatly appreciate your feedback on a practice application that I have developed. The application consists of a Spring Boot backend ...
thebluepandabear's user avatar
-3 votes
0 answers
59 views

Is it ever a good idea to wrap your DTOs in a custom Data object? [closed]

Is it ever a good idea to wrap your DTOs in a custom Data object? My thinking is you don't need any Data to include more than ...
Sergey's user avatar
  • 155
1 vote
2 answers
84 views

Search/Query API cross parameter check

Background I was working on a coding challenge as part of an interview process. I had to create a REST API where the user can report sensor data and query derived metrics based on several filter ...
Peter Csala's user avatar
  • 8,024
0 votes
0 answers
8 views

Buggy auto conversion to string : In which code-smell would it fall and how should avoid one? [migrated]

Consider this Java code: int rawIndex=8; int offset=0; libFuncCall.populate("B"+rawIndex+offset, data); Here I mistakenly missed the fact that, ...
MD. Mohiuddin Ahmed's user avatar
4 votes
1 answer
79 views

Spring REST Endpoint for Saving a User Inquiry

Here's a piece of code from codebase I maintain/contribute to. It is a Spring REST controller, which exposes an endpoint to create user question. The question consists of title, description and ...
Sergey's user avatar
  • 155
0 votes
1 answer
48 views

The Matrix Winds In

The Problem: Given an N by M Matrix, Create an Anti-Clockwise Traversal Path that winds in all the way into the Matrix Example: The Matrix is 9 by 5 Output: ...
Amal Krishnan's user avatar
0 votes
2 answers
43 views

Send sorted, signed requests

This is part of the code I wrote in Java yesterday. It is for sending a body request with some parameters as a pair of keys and values, in a sorted list. Also, this list must have a signature, or the ...
user avatar
0 votes
0 answers
34 views

Report generation code using Jasper and Spring boot

This outputs the report in HTML. This fetches all records for an entity and then lists them in the report. Wondering if this can be made generic, right now it is only one entity and 2 fields. Also ...
darthdearth's user avatar
3 votes
1 answer
98 views

String Permutation Implemention

The objective is simple: List all possible permutations for a given a String. I looked at some implementations from popular sources. I decided to build this to the flow: The Code for Review ...
Amal Krishnan's user avatar
4 votes
4 answers
1k views

Quick Sort Done Lucidly

I've been away from Programming and the Tech Industry for sometime. I thought I'd look at and try some of the older basic stuff. I bushed up to QuickSort and found most existing implementations of it, ...
Amal Krishnan's user avatar
2 votes
1 answer
52 views

Interest/Discount rate and loan calculator java

I'm currently learning Java at home with YouTube tutorials. I took a short break from the course to make a small project for calculating costs of loan. It's not economically accurate - I followed ...
Koros's user avatar
  • 23
3 votes
1 answer
59 views

Optimize Island Counter program

I am doing some assignments on my own and one of them is about a Island Counting program, I have come up with a working program but the problem is its very slow. When running test on for example maps ...
phuck's user avatar
  • 33
1 vote
1 answer
82 views

A vanilla Hibernate app (no Spring)

I finished my web project a while ago and decided to revisit one my first Java projects – the first project that had anything to do with databases. It looked pretty messy to my more experienced eye. ...
Sergey's user avatar
  • 155
1 vote
1 answer
64 views

Creates all possible permutations of a string and its substrings

I want to improve this code to efficiently create all possible permutations/combinations of a string. For example, if I have the string "abc", the result would be the list [ab, ac, ba, bc, ...
themightye's user avatar
2 votes
1 answer
45 views

Parsing one UserData type to a preview

I am currently developing a web app and am using Spring as a Backend. I have some user data that is provided by one of our services and I need to display it in my frontend. The subject of the code ...
monamona's user avatar
  • 425
2 votes
0 answers
55 views

Java Project Reactor/WebFlux token service

I'm trying to achieve a thread-safe reactive token service. The point is that all subscribers must wait until the token is received or updated (when expired). It works, but I want a second opinion ...
John Goode's user avatar
0 votes
1 answer
62 views

Retrieve data from an XML file in Java

few months back I did a code test for a company and I quickly managed to solve it within 5-10 minutes. But, I got rejected because it wasnt "good enough". What is good enough? they said its ...
Con101's user avatar
  • 3
-2 votes
1 answer
98 views

How do I ensure my Java method never returns null? [closed]

I've been reading Uncle Bob's Clean Code and have read many articles on the use of Optionals whenever you are faced with returning a null in a Java method. I'm currently refactoring my code and I ...
Mark's user avatar
  • 107
0 votes
2 answers
65 views

Code that checks whether there is a holiday by calling another microservice

I call another microservice to check whether there is any holiday on any particular day. This will then add a comment in the db if the rest call doesn't fetch an empty list(a list of size 1). Here is ...
diaop's user avatar
  • 9
2 votes
0 answers
51 views

MVVM signing in using firebase

I'm new to MVVM architecture. I want to have authentication with email + password, google and Facebook. I'm not sure if there should be separate view models for each authentication way: ...
Edziu Kowalski's user avatar
1 vote
0 answers
37 views

Print columns of text without hard coding the width (attempt 6 - pivot edition)

If you'd like to pivot this: ...
candied_orange's user avatar
6 votes
1 answer
128 views

Crossword puzzle app

I was hoping someone could give me any tips or advice on this program I wrote for my high school class. The point of the program is to create a workable crossword puzzle in the console. If it works ...
Sean Riley's user avatar
1 vote
0 answers
119 views

The right way to implement multiple commands in a Telegram bot

I started coding two months ago and as my first project I wrote a Telegram bot in Java. The purpose of the bot is to perform various tasks related to the Yugioh TCG (such as searching for cards in a ...
smnprn's user avatar
  • 11
4 votes
0 answers
65 views

Print columns of text without hard coding the width (attempt 5)

If you'd like to print this: ...
candied_orange's user avatar
1 vote
1 answer
82 views

Queue-mergesort: a mergesort that does optimal number of comparisons in the worst case in Java

Here is the code for queue-mergesort by Mordecai J. Golin and Robert Sedgewick: com.github.coderodde.util.QueueMergesort.java: ...
coderodde's user avatar
  • 26.7k
4 votes
2 answers
168 views

Multithreaded Conway's Game of Life implementation written in C and Java using JNI

I had some multithreading C programming experience from school last year but I wanted a bit more so I tried to program a Conway's Game of Life implementation from scratch. Code is mainly written in C ...
Shmuel Newmark's user avatar
2 votes
0 answers
78 views

A simple probabilistic AI for generating random sentences in Java

Motivation I have this repository. It contains a program that analyzes an input text file and builds a word graph: in the graph, each node represents a word in the analyzed text. Now, if there are two ...
coderodde's user avatar
  • 26.7k
3 votes
3 answers
119 views

IPv4 filter in Java

I have a simple class for representing IPv4-addresses via int values, and a simple IP-address filter that works like a set of IPv4-addresses. ...
coderodde's user avatar
  • 26.7k
3 votes
1 answer
115 views

Calculator (Java/Beginner)

I finished my first calculator using Java! I try to apply Object-Oriented Programming! I'll add my gitHub link if you're suited to viewing code on gitHub. Here is a link to my GitHub Calculator ...
dddleo's user avatar
  • 33
2 votes
3 answers
448 views

Recursive palindrome check

I'm trying to solve this which basically calls for a recursive palindrome check with some minor extra steps (Special characters and whitespace can be ignored). The test inputs' length can be 100000 ...
YaMiN's user avatar
  • 125
0 votes
3 answers
215 views

Print columns of text without hard coding the width (attempt 4)

If you'd like to print this: One Two Three Four 1 2 3 4 using this: ...
candied_orange's user avatar
0 votes
0 answers
48 views

Print columns of text without hard coding the width (attempt 3)

If you'd like to print this: One Two Three Four 1 2 3 4 using this: ...
candied_orange's user avatar
4 votes
1 answer
246 views

Print columns of text without hard coding the width (attempt 2)

If you'd like to print this: One Two Three Four 1 2 3 4 using this: ...
candied_orange's user avatar
5 votes
2 answers
153 views

Recipe search exercise

I'm currently following Java moocfi Helsinki course. This is my current assignment : In this exercise we are going to create a program that allows for searching for recipes based on their name, ...
FakiB's user avatar
  • 51
3 votes
1 answer
92 views

Print columns of text without hard coding the width

If you'd like to print this: One Two Three Four 1 2 3 4 using this: ...
candied_orange's user avatar
3 votes
1 answer
163 views

My First Java Battleship Simulator (single array, single ship)

I'm new to this community and also to Java programming! I recently picked up "Head First Java" and I did my Battleship project. If you could kindly, give me feedback on the code? ...
java_grindr's user avatar
5 votes
2 answers
243 views

Select the type of triangle based on the input

I am trying to see if there is a way to improve my code this program ask for 3 number and calculate the what type of triangle it is ...
L1avZh's user avatar
  • 53
2 votes
0 answers
37 views

Testing CRUD ops with some special cases using Cucumber

Question Using Cucumber and Java17, I refactored functional tests for a basic CRUD app as I found the previous tests using special variables for different test scenarios and I felt they were brittle ...
Ahmed Tawfik's user avatar
1 vote
1 answer
64 views

Greedy approximate algorithm for metric TSP in Java

I have a repository that provides three metric TSP solvers: Brute-force solver, Genetic solver, Greedy approximate solver; solver 3 is the subject matter of this post. The typical output is: ...
coderodde's user avatar
  • 26.7k
2 votes
1 answer
77 views

Java program for complex math utilities

I've got 2 Java programs, with the aim of solving some matrix math that involves complex numbers (an EE problem). Both programs have main functions, the one with all the complex math operations has a ...
Aloy's user avatar
  • 21
1 vote
3 answers
78 views

Extensible error code infrastructure

I was answering a question, Java Exception Error Enumerations Anti-pattern, on Software Engineering Stack Exchange and found myself writing up a fair bit of code. It could use a code review so I'm ...
candied_orange's user avatar
0 votes
0 answers
29 views

Fee Challan as a practice in Java Swing,

I have made three classes and I have put all the UI code in a different class and used method for labels, text fields etc so it does not mix up. Please look into this code and tell me is it good ...
touqeer's user avatar
  • 101
8 votes
1 answer
149 views

Java code for generating 16bit DMX values using sine and cosine

This is my try, based on good inputs from different places. I ended up saving the DMX-values in two arrays (one for sine and one for cosine) as I guess that will make stuff easier later on when I want ...
droid's user avatar
  • 83
0 votes
1 answer
73 views

Reversing in between a linked list

I have written code for this leetcode problem :- Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from position left to ...
Strange Alchemist's user avatar
8 votes
2 answers
2k views

Shell script to compile Java

...
user16217248's user avatar
1 vote
0 answers
96 views

Making Robert Tarjan's offline LCA algorithm run (much) faster (Java)

I have produced this GitHub repository that compares the performance of: Robert Tarjan's off-line lowest common ancestors algorithm, An improvement of the above algorithm. Typical demo program ...
coderodde's user avatar
  • 26.7k

1
2 3 4 5
217