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.
10,883 questions
0
votes
0
answers
2
views
PathFinding.java: Beam search in Java
Intro
I am currently working on this project (PathFinding.java). This time, I need to get the following class reviewed:
Code
...
0
votes
0
answers
29
views
CodeView Custom JavaFX Node
I created this to learn about creating custom controls using Region. I did not do any testing of the Control, and it is limited to displaying Java only. I didn't need this for any reason other than ...
5
votes
1
answer
303
views
PathFinding.java: The grid view and model
Motivation
I am really fond of qiao/PathFinding.js, and, so, I decided to start to do something similar (PathFinding.java). Also, this time, I am wishing to practice some MVC-patterns. It would seem ...
8
votes
2
answers
582
views
Own HTTP server implementation in Java with a simple template engine
I would like to hear what you think about my simple HTTP Server implementation with a template engine in Java.
Have I overlooked any "pitfalls or caveats", or is there anything else to note?
...
3
votes
1
answer
151
views
Java: counting letters FROM A fractal algorithm shows prime number patterning
This example finds all "letter" structures.
letter a = LMLMMM
letter b = LMMMMM
letter c = MMLMMM
letter d = MMMMMM
Symbol L = live = prime candidate number
Symbol M = multiple = composite ...
1
vote
3
answers
134
views
Is this exception handling missing anything?
This is the code. I'm uncertain about the last block.
...
2
votes
0
answers
53
views
Funny time with DNA: a \$k\$-mer index data structure in Java, Take II
(See the previous and initial iteration.)
Intro
This time, I decided to pack the genomic data such that 4 nucleotide bases are encoded into a single byte. In other words, ...
4
votes
1
answer
91
views
Funny time with DNA: a \$k\$-mer index data structure in Java
(See the next iteration.)
This time I have programmed a simple data structure called \$k\$-mer index. The actual word \$k\$-mer is a synonym of substring of length \$k\$. This data structure is built ...
5
votes
1
answer
449
views
Java: prime number envelopes FROM A fractal algorithm shows prime number patterning
It implements prime number envelopes (page 3) from my paper: https://zenodo.org/records/16829092
The full working example is on github: https://github.com/cerebrummi/primeenvelopes
"StartFA"...
10
votes
2
answers
1k
views
Java: A fractal algorithm shows prime number patterning
The fully working example finds all primes (theoretically). In real life the FA is constrained by stack size. The theoretical run is important, because it proves that all primes have a deterministic ...
4
votes
3
answers
657
views
Multithreaded array summation in Java - best practice, structure, acceptable use of Constant classes. There is no concurrency?
The task is educational. The basic functionality is working. Here are some questions for my code. Please give me feedback.
Main:
Architecture & Design: Is the decomposition appropriate? Should ...
5
votes
6
answers
940
views
The Haversine formula in Java for computing distance along the Earth between two locations expressed in geographical coordinates
This time, I have implemented the Haversine formula:
io.github.coderodde.geom.Haversine.java:
...
4
votes
2
answers
276
views
Alternate two messages on mouse click using Java-FX
Write a program to display the text Welcome to Java and LearningJavaFX alternately with a mouse click.
...
5
votes
1
answer
385
views
Positive Integer Class Supporting Arbitrary Number of Digits
I have implemented an elementary positive integer class that supports addition, subtraction, and multiplication for an arbitrary number of digits using a singly linked list.
...
2
votes
0
answers
90
views
Simple image captcha test in Java and JS (revised version)
Following on from my previous question, I would like to know what could be improved here and whether it is now secure.
I had to use Java 8 because the Blade lib was built with it, and I want to extend ...
4
votes
1
answer
103
views
Implement a simple image captcha test yourself in Java and JS
First of all: I was looking for a simple image captcha solution for a website, but all I found were "Over-the-top" solutions for me. So I decided to write something to self.
I mainly use two ...
2
votes
1
answer
96
views
Code to add order orderitems and payment details
This is order, orderitems and payment linked by foreign key.
Controller:
...
4
votes
2
answers
163
views
SimpleStackMachine.java - A virtual stack machine written in Java
In this post, I present my most recent result, a stack-based virtual machine programmed in Java. Frankly, I am lazy to write the unit tests since I am pretty much burned out with it. The full ...
1
vote
0
answers
51
views
Lock free Leaky Bucket Rate Limiter
I want to validate my solution for a lock-free leaky bucket rate limiter. Given a queuing capacity and rate limit per second, it should queue requests till capacity is reached and it should allow only ...
1
vote
0
answers
37
views
Spring Boot RabbitMQ Publisher Configuration for Sending JSON Messages
The publisher class:
...
2
votes
3
answers
168
views
Calculating volume expressions of \$n\$ -dimensional balls in Java - follow-up 2
(See the previous iteration.)
This time, I have refactored my code a bit. It follows immediately:
Code
...
4
votes
2
answers
219
views
Calculating volume expressions of n -dimensional balls in Java - follow-up
Intro
(The previous/initial iteration is there.)
(The next iteration is there.)
This time, I have incorporated a nice answer by Martin R.
Updated code
...
4
votes
1
answer
321
views
Calculating volume expressions of \$n\$-dimensional balls in Java
(See the next iteration.)
Intro
This time I have a Java program that prints some expression denoting the volumes of \$n\$-dimensional balls. All the math behind this is there.
Code
...
1
vote
0
answers
57
views
Fixed BIDDFS (bidirectional iterative deepening depth first search) in Java
Intro
I have this GitHub repository for doing pathfinding in directed unweighted graphs. This post is about BIDDFS proposed by Richard Korf in his paper.
Code
...
1
vote
0
answers
68
views
IndexedLinkedList.java - A fast list data structure for large data, Take V/V (the finger list)
Intro
This post is all about so called finger list, which is a data structure for speeding up the
linked-list operations.
Code
...
1
vote
0
answers
17
views
IndexedLinkedList.java - A fast list data structure for large data, Take IV/V (inner classes)
Intro
This post is the continuation of IndexedLinkedList.java - A fast list data structure for large data, Take III/V (private API).
Code
...
1
vote
0
answers
21
views
IndexedLinkedList.java - A fast list data structure for large data, Take III/V (private API)
Intro
This post is the continuation of IndexedLinkedList.java - A fast list data structure for large data, Take II/V (package private API). It presents the private methods only.
Code
...
1
vote
0
answers
25
views
IndexedLinkedList.java - A fast list data structure for large data, Take II/V (package private API)
Intro
This post is the continuation of the IndexedLinkedList series. It presents the package private API:
Code
...
1
vote
1
answer
63
views
IndexedLinkedList.java - A fast list data structure for large data, Take I/V (public API)
Intro
I have this Java implementation of a list data structure that outperforms on a benchmark even the Apache Commons Collection4 TreeList by a factor of 8.
This ...
5
votes
3
answers
743
views
A simple checksum for java.math.BigInteger
Intro
I have a simple methods that converts the input instances of java.math.BigInteger to checksum. The checksum algorithm sums up all the digits in the input <...
1
vote
0
answers
72
views
A parallel MSD radix sort in Java for long keys with near linear speedup
Intro
I have this implementation of a parallel MSD (most significant digit) radix sort. It runs in
$$\mathcal{O}\Bigg( \bigg(\frac{N}{P} + PB \bigg) \log_B \sigma\Bigg),$$ where \$N\$ is the length of ...
3
votes
0
answers
54
views
TextSearchField — search field for JTextArea
Here's a search field that I wrote for our project.
What do you think?
Shortcuts
Ctrl+F Show the search field.
Ctrl+F (when the ...
3
votes
0
answers
151
views
Java Swing Layout Manager: TrainLayout, TotemLayout, BullsEyeLayout (together called TOnion layout)
This is my code of the Java Swing LayoutManager that I wrote for Cerebrummi vocabulary trainer. Screenshots
I made it available (version 3.0) on github to be used freely.
Unfortunately it was never ...
6
votes
2
answers
311
views
Visualize Python data in JavaFX with Py4J
For a larger project, I need to build a bridge between a Python and a Java programme. I decided to use Py4J and constructed a smaller problem to familiarise myself with the first steps.
Java is ...
6
votes
2
answers
874
views
ParallelSudokuSolver.java: solving semi-large Sudokus via multi-threading
Intro
This time, I have programmed a parallel sudoku solver in Java.
Code
io.github.coderodde.sudoku.ParallelSudokuSolver.java:
...
1
vote
2
answers
154
views
ProducerConsumerSimulation.java: practicing concurrent programming in Java
Intro
This time, I was in the mood for concurrent programing (ProducerConsumerSimulation.java). To this end, I have ended up with the code below. My primary concerns are:
Class design is trash,
The ...
3
votes
2
answers
555
views
Accuracy issues with float-based cosine approximation using Taylor series in Java
I'm working on a Java assignment where I must implement the cosine function using only basic arithmetic operations (addition, subtraction, multiplication, division) and no built-in math functions, ...
1
vote
0
answers
30
views
LibID: a Java library containing some iterative deepening algorithms for pathfinding on directed unweighted graphs
Intro
I have this GitHub repository containing some iterative deepening pathfinding algorithms.
Code
...
1
vote
0
answers
43
views
IndexTupleIterator.java: an iterator that generates index tuples in lexicographic order, Take IV
(See the previous iteration here.)
This time, I have incorporated the answer from YawarRaza7349.
Now, my code looks like this:
...
3
votes
3
answers
205
views
IndexTupleIterator.java: an iterator that generates index tuples in lexicographic order, Take III
(See the next iteration here.)
(See the previous iteration here.)
This time, I have incorporated a nice answer from Simon Forsberg.
Now, my code looks like this:
...
1
vote
1
answer
51
views
IndexTupleIterator.java: an iterator that generates index tuples in lexicographic order, Take II
(See the previous iteration here.)
(See the next iteration here.)
This time, I improved the iterator such that there is no chance of numeric overflow when computing the total number of iterations. To ...
5
votes
3
answers
1k
views
Method using double for currency amounts
I'm wary of using amount as double. This API also has to maintain backward compatibility. Would appreciate for any comments on this method.
...
1
vote
0
answers
39
views
Spring AI 1.0.0 configuration setup with custom bean definitions
I've recently shifted from SpringAI M5 to 1.0.0 which is a major change and just wondering if there is a better way to organise SpringAI configurations. I'm using Azure OpenAI based connection along ...
4
votes
1
answer
76
views
IndexTupleIterator.java: an iterator that generates index tuples in lexicographic order
(See the next iteration here.)
Intro
This time, I have an Iterator<List<Integer>> implementation that generates list index tuples in lexicographic order....
10
votes
4
answers
670
views
Java method to resize, flatten PNG transparency, and compress Base64 image to JPEG using ImageIO
I wrote a method (code below) to optimize the size of an image that is used as a logo, the code does the following:
Resizes images wider than 720px (keeps aspect ratio)
Flattens PNG transparency onto ...
5
votes
2
answers
435
views
Java file reading with BufferedReader
This worked for me, and it's what I'm familiar with, but it's too complex. I would like to get an easier solution, if there is one, and it works the same way. How important is error handling? Can it ...
5
votes
2
answers
826
views
Bruteforce integer multiplication in Java
Intro
This time, I have attempted to prove the following bruteforce multiplication formula:
$$
(a_n \cdots a_0) \cdot (b_m \cdots b_0) = \sum_{i = 0}^n \sum_{j = 0}^m a_i b_j \cdot 10^{i + j},
$$
...
2
votes
2
answers
104
views
handling different scenarios for string separated by space , comma and new line
I have the following code where I'm handling a product barcode based on how it is separated by, which can be a comma, space and new line. Can someone tell me if it can be improved? I was thinking of ...
6
votes
1
answer
569
views
Substring = Permutation of a given pattern
I am working on a problem on LeetCode.
Considering only lowercase characters from 'a' to 'z', I have written some Java code to check if a permutation of a given pattern is a substring of a given ...
1
vote
1
answer
205
views
Method to check if date submitted is the 25th hour of the 25 hour day
I'm writing a method that performs the following. I believe I have all of my bases covered but I want to make certain.
Biggest question is am I referencing the 25th hour correctly?
Calculate the 25-...