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 vote
0 answers
34 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 ...
  • 26.5k
-3 votes
0 answers
20 views

Payment Service with Java, Spring [closed]

At the interview, they gave such a code, it was necessary to find flaws ...
  • 1
3 votes
3 answers
99 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. ...
  • 26.5k
3 votes
1 answer
60 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 ...
  • 33
2 votes
3 answers
411 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 ...
  • 125
0 votes
0 answers
75 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: ...
0 votes
0 answers
37 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: ...
4 votes
1 answer
211 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: ...
5 votes
2 answers
64 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, ...
  • 51
3 votes
1 answer
80 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: ...
3 votes
1 answer
120 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? ...
5 votes
2 answers
218 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 ...
  • 53
2 votes
0 answers
25 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 ...
2 votes
1 answer
72 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 ...
  • 21
1 vote
3 answers
73 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 ...
0 votes
0 answers
22 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 ...
  • 101
8 votes
1 answer
143 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 ...
  • 83
0 votes
1 answer
65 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 ...
8 votes
2 answers
2k views

Shell script to compile Java

...
1 vote
0 answers
86 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 ...
  • 26.5k
5 votes
1 answer
269 views

Merge multiple map with java stream api

I am trying to merge multiple map with Java stream API. The reqiurements like ... this method can receive multiple map, does not care hot many of it support 2 merge method: intersection, union if key ...
0 votes
0 answers
65 views

An extended simple, funny, easy linked stack of lists in Java

This post is the continuation of A simple, funny, easy linked stack of lists in Java. What's new: Now I have varargs for pushing/linking multiple values per call. Provided the unit tests. ...
  • 26.5k
0 votes
0 answers
54 views

A simple, funny, easy linked stack of lists in Java

(See also the next iteration.) (This data structure can be implemented as Deque<List<T>>, yet I decided to have some better time with it. :-)) ...
  • 26.5k
0 votes
0 answers
59 views

Bruteforce proof of an arithmetic expansion scheme expression in array lists (Java)

Given a list of, say, integers, one way to implement such a list is to rely on an array under the hood. When we are adding elements to the array list, we might need to make the internal array larger. ...
  • 26.5k
4 votes
1 answer
273 views

Hangman game, with secret word provided by user

I recently started learning programming and in particular Java. I wrote this small hangman game which takes the input for the secret word from the user. It all works as intended; I would like to know ...
2 votes
2 answers
152 views

Quick Sort Program

Quick sort is a sorting algorithm in which we select any random element as pivot from the array and we do the partition of the array around that pivot. Basically we place all the elements smaller than ...
3 votes
0 answers
59 views

JavaFX dialog for numeric typed data input

I have this small subclass of JavaFX's javafx.scene.control.Dialog that requires the enum specifying the data type of the input data: ...
  • 26.5k
-3 votes
1 answer
104 views

Default food property wording when translation not available

I have food table having number of foods, each food can have specific properties in multiple languages (en, es) like name, description etc. But it is not sure if all of the properties are always ...
2 votes
1 answer
55 views

Merge Sort with Minimum Sufficient Variables, Verbosity and better Space Complexity

The majority of merge sort implementations searched online are provided with unnecessary variables and code lines. Here is an attempt to reduce that. However, does passing back the subArray as return ...
1 vote
1 answer
105 views

Interconnect Recipe and Notes

I'm currently working through a tutorial. The project is a recipe website. One of the lessons to "save some lines of code" and use bidirectional setters for bidirectional relations of ...
0 votes
1 answer
65 views

Implement code to monitor file delete action

I have this Java code which I want to use to monitor file changes into directory: ...
1 vote
0 answers
41 views

Spring boot shop application with error handling

I'm writing a simple online shop using spring boot, for learning purposes. Right now I have purchasing-service and a product-service. The purchasing-service makes requests to the product-service via ...
  • 243
0 votes
1 answer
79 views

Printing Permutations

Following is a leetcode problem: Given an array nums of distinct integers, return all the possible permutations. You can return all the possible permutations. You can return the answer in any order. ...
0 votes
1 answer
57 views

Delayed, concurrent event stack in Java - follow-up

I have slightly refactored the Delayed, concurrent event stack in Java. Now it looks like this: DelayedEventStack.java ...
  • 26.5k
0 votes
3 answers
185 views

Delayed, concurrent event stack in Java

(See the next iteration: Delayed, concurrent event stack in Java - follow-up ) Motivation I was confronted with a task of having "message events" for a GUI program. The use case is as ...
  • 26.5k
4 votes
2 answers
179 views

Multiplayer queue optimisation

I currently have code that is working but I think it can be optimised. The code waits until a player joins and adds the player to a BlockingQueue if there is not already a Player waiting then it ...
  • 43
0 votes
1 answer
71 views

First try at Java annotations and using them to change instance values

I was curious on how annotations are used during runtime, so after some googling I gave it a try, but kinda have the feeling that is not the proper way as I still have to call the annotation helper on ...
  • 53
0 votes
1 answer
65 views

How can I refactor getAll() method for the service business logic? [closed]

I'm working with the following project, where I have business-logic as: ...
  • 121
3 votes
1 answer
85 views

Company management app: Extracting data with JDBC and java.sql

I'm currently working on a company management system as a university project, and I have to get my hands in java.sql. I have come to struggle with extracting a ...
0 votes
0 answers
55 views

How to refactor findAll() for finding products method in more proper way?

I'm working with the following code snippet of the ProjectController class as below: ...
  • 121
4 votes
2 answers
107 views

Designing a basic Binary Expression Tree structure

Preface I need to generate some algebraic expressions for math testing in elementary school. The test should generate a list of expressions compiled according to certain rules and check the ...
  • 495
-2 votes
1 answer
165 views

Number Plate Generation Program

I wrote a number plate generation program. The program generates number plates for a car registered with a specific Memory Tag and on a specific date. Number plates use the following format: (2 letter ...
1 vote
0 answers
88 views

Restaurant Management follows MVC pattern

I am writing the Restaurant Management homework which must be following the MVC pattern. My Menu model has two parts: Drink menu and Food menu. With Food menu, it separates into three different types ...
3 votes
1 answer
90 views

An encryption/decryption program with two different algorithms, Caesar Cipher and a Unicode Cipher

This project was part of the JetBrains Academy Java course. The project was about implementing an Encryption program that uses either a simple Caesar Cipher (or) a Unicode Cipher depending on the ...
1 vote
2 answers
87 views

Having a separate validation util for common checks

I am working on a project where I see the following methods wrapped in a Util class ...
  • 608
4 votes
1 answer
168 views

Find largest number of collinear points

The following is my submission for LeetCode's Max Points on a Line: Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane, return the maximum number of points that ...
  • 141
1 vote
3 answers
73 views

FileIO lines to String Converter

I think I made a good FileIO object because I can simply copy-paste whenever I need, however I wonder How I can improve my code. This code takes file path of the target file and turns every line to ...
  • 13
0 votes
2 answers
153 views

Functional Style if/else in java

I would like to ask the opinion for experts out there. The following code snippet was written by a colleague of mine who is very fond of functional style in Java. ...
6 votes
4 answers
2k views

Printing a Hollow Butterfly pattern

I am a beginner to Java and have studied up to loops only. After loops lecture above pattern was given to print as homework. I have successfully managed to print this pattern with following code: <...
1 vote
1 answer
51 views

Take meal orders from breakfast, lunch and dinner menus

I have an exercise requires me to write a service to management menu. The requirement like this: Food menu includes: breakfast menu, lunch menu, dinner menu. The three menu haves list menu item( name, ...

1
2 3 4 5
217