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
0 answers
8 views

A test class for a REST application

Here's a suite of integration tests for my REST controller. Among other thing, it reflects my efforts to reduce code duplication. First, I introduced some class fields. ...
Sergey's user avatar
  • 161
0 votes
1 answer
18 views

Naming of api calling methods to get an object by two different properties

I have the situation, where I have to methods in my api calling class that do basically the same thing. I have a profile that contains multiple account objects. These objects have their own UUID as a ...
monamona's user avatar
  • 425
0 votes
0 answers
11 views

Retrieving a rich domain model from persistence

So I've been looking at these questions trying to find an answer, but no luck https://stackoverflow.com/questions/23314330/rich-vs-anemic-domain-model https://stackoverflow.com/questions/42286611/how-...
Omar Gamil's user avatar
4 votes
2 answers
89 views

Merge a list of deeply nested HashMaps

Suppose I have a list of hashmaps (<String, Object>). Values can be either scalar types or a nested HashMap with the same type. I need to merge a list of this ...
Cristian's user avatar
  • 161
-2 votes
0 answers
18 views

Printing the original list, Hoare's list, and Lomuto's list in Java [duplicate]

This is my first attempt at Quick Sort using Java and I am also looking for some helpful criticisms on how I can make my code better. ...
Mike Miller's user avatar
-4 votes
0 answers
14 views

How to detect a thrown item in modding and allow it to be interacted with - Minecraft Java [closed]

I am working on a huge project, a mod for minecraft and I am trying to figure out how to locate or detect a thrown item and potentially assign that result to a variable or use a class to do this, what ...
How do i....'s user avatar
-2 votes
0 answers
37 views

Quicksort using two different partition functions [closed]

This is my first attempt at Quick Sort using Java. I am looking for some helpful criticisms on how I can make my code better. ...
Mike Miller's user avatar
0 votes
0 answers
56 views

Simulation: Find a waiting queue order that minimizes the total waiting time - Java

Intro Suppose we are given a queue of waiting times \$\langle t_1, \ldots, t_n\rangle\$. The first "person" \$(t_1)\$ leaves the queue immediately. The persons \$(t_i), i > 1\$ all have ...
coderodde's user avatar
  • 26.7k
1 vote
1 answer
64 views

Beginner Java Tic-Tac-Toe

I had a Tic Tac Toe assignment for class and the program seems to work fine but I feel like the exception/input handling could be done in a much better way. Is this a good way to approach the ...
Drosos-kal's user avatar
1 vote
1 answer
39 views

Thread-safe resource disposal

I've been using Guava Closer for non-trivial resource life-time management. It is not thread-safe, and occasionally there is a need for a multi-threaded resource allocation. I could not find a library ...
Basilevs's user avatar
  • 111
3 votes
3 answers
66 views

Calculate Parking Fees

Here's the description: Please write a Java Program for managing parking fees. each hour is $3. The invoice has to contain: ID, amount, and subtotal. The maximum fee of the day is $30, and give out ...
Jen's user avatar
  • 31
-4 votes
2 answers
55 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
437 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
32 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
66 views

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
1 vote
2 answers
116 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,099
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
80 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
  • 161
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
107 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
54 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
86 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
  • 161
1 vote
1 answer
66 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
47 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
57 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
63 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
-3 votes
1 answer
102 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
  • 105
0 votes
2 answers
66 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
57 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
40 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
129 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
124 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
84 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
169 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
120 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
119 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
159 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
93 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
165 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
244 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

1
2 3 4 5
217