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,906 questions
4
votes
1
answer
24
views
A Java program for compressing/decompressing files via Huffman algorithms
Intro
(The full repository is here. It contains also some unit tests that do not fit in this post due to size limits.)
I am making my very first steps in data compression, and so, decided to practice ...
-4
votes
0
answers
45
views
Object oriented programming deque implementation (after another second thought)
After another second thought from the second thoughts series Object oriented programming deque implementation (after second thought) it turns out using static methods alternatively to method ...
2
votes
1
answer
108
views
Huffman code builder in Java - computing prefix codes for arbitrary (generic) alphabets - Take II
Intro
(This is the continuation of HuffmannEncoder.java - computing prefix codes for arbitrary (generic) alphabets.)
(See the GitHub repository.)
This time:
I have fixed the misspelled ...
4
votes
2
answers
340
views
HuffmannEncoder.java - computing prefix codes for arbitrary (generic) alphabets
(See the continuation of this post at HuffmanEncoder.java - computing prefix codes for arbitrary (generic) alphabets - Take II.)
I have this Java implementation of the Huffmann encoding. It looks like ...
-1
votes
2
answers
178
views
Object oriented programming deque implementation (another second thought)
Another second thought from the second thoughts series Object oriented programming deque implementation (after second thought) led to disposing if statements ...
2
votes
2
answers
838
views
Three non-negative integer encoding techniques in Java
Intro
In this post, I will present three (3) non-negative integer encoding techniques:
Elias gamma coding
Elias delta coding
Golomb-Rice coding
Code
...
4
votes
3
answers
468
views
A simple method for compressing white space in text (Java) - Take II
Intro
In this post, I will elaborate on A simple method for compressing white space in text (Java). Here, I have incorporated some advice offered by Chris. Also, this version preserves a single new ...
2
votes
2
answers
252
views
Benchmarking in Java some super linearithmic sorting algorithms
Intro
A sort is called super linearithmic if its running time is \$\omega(N \log N)\$. For example, \$f(N) = \omega(g(N))\$ means that \$f(N)\$ grows "faster" than \$g(N)\$. In this post, I ...
5
votes
1
answer
524
views
A simple method for compressing white space in text (Java)
(The story continues in A simple method for compressing white space in text (Java) - Take II.)
Intro
Now I have that text space compressor. For example,
...
-6
votes
1
answer
122
views
Object oriented programming deque implementation (after second thought)
The java.util.Deque implementation from Object oriented programming deque implementation that consists of three elements linked arrays, each array holding reference ...
2
votes
1
answer
145
views
ShannonFanoEncoder.java - computing prefix codes in Java
Intro
This time, I have implemented the Shannon-Fano coding.
Code
io.github.coderodde.compression.ShannonFanoEncoder.java
...
1
vote
1
answer
108
views
Jump point search in Java for faster pathfinding in grid mazes
(Refer to the entire repository in GitHub.)
How it looks like
Intro
This time, I present my take on Jump point search that I translated from Javascript (PathFinding.js/src/finders/JumpPointFinderBase....
4
votes
1
answer
89
views
Dijkstra's algorithm for non-uniform undirected hypergraphs: Take II - bidirectional Dijkstra's algorithm with excellent performance
Intro
(See the full repository here.)
A non-uniform undirected hypergraph is a generalization of an undirected graph. It is defined as \$H = (X, E)\$, where \$X\$ is the set of vertices and \$E \...
4
votes
1
answer
180
views
API having flow - normal flow along with background poller(it also involves events which is not shown here)
We have an API in which we call external service with a tracking id.This first part of the API workflow makes an entry to the DB as SUBMITTED after the call to first external API say /E1 finishes and ...
0
votes
1
answer
82
views
Computing loan cuts leading to a global zero equity in a financial graph (Java)
Intro
I won't specify the problem here, but instead, provide the link to the blog post discussing the problem and the full implementation.
Code
...
4
votes
2
answers
142
views
Dijkstra's algorithm for non-uniform undirected hypergraphs
Intro
(Repo here.)
A non-uniform undirected hypergraph is a generalization of an undirected graph. It is defined as \$H = (X, E)\$, where \$X\$ is the set of vertices and \$E \subseteq \mathcal{P}(X)\$...
-4
votes
1
answer
112
views
Deque implementation around strategy design pattern
Implementation of java.util.Deque interface based on string of POJOs, that is plain old java object, encapsulating a field for holding reference to each object ...
5
votes
2
answers
418
views
Ordinary insertion sort vs. straight insertion sort in Java (benchmark)
Intro
So this time I wanted to find out which of the two insertion sort flavours are faster:
Code
io.github.coderodde.util.StraightInsertionSort.java:
...
0
votes
0
answers
60
views
Computing \$k\$ most reliable paths in undirected probabilistic graphs in Java
Intro
(See MostProbablePath.java.)
This time, I elaborate on Computing most probable (reliable) path in a probabilistic graph (take II): instead of computing the most reliable path I now return \$k\$ ...
4
votes
1
answer
286
views
Computing most probable (reliable) path in a probabilistic graph (take II)
Intro
A probabilistic graph \$G = (V, E)\$ is an undirected graph with weight function \$w \colon E \rightarrow [0, 1]\$. In the most reliable path problem we -- given two terminal nodes \$s \in V\$ ...
0
votes
0
answers
76
views
Wrap java.awt.GridBagLayout
I appreciate the GridBagLayout of Java very much.
But, it has one huge disadvantage: it is very much boilerplate code. You have to type too much.
I would like to use the GridBagLayout of Java in the ...
1
vote
0
answers
64
views
PathFinding.java: Drawing a random perfect maze via randomized DFS
Intro
Still working on PathFinding.java. This time I concentrate on three private methods of GridModel that are responsible for generating random perfect mazes. A maze is perfect if for each two cells ...
2
votes
2
answers
106
views
Checking for weak string isomorphism in Java
Intro
I call two \$n\$-strings \$s\$ and \$z\$ over the alphabet \$\Sigma\$ weakly isomorphic if their character frequency multisets are equal. In other words, for an input strings \$s\$, we derive a ...
4
votes
1
answer
168
views
Checking for string isomorphism in Java
Intro
Two \$n\$-strings \$s = \langle s_1 \ldots s_n \rangle \$ and \$z = \langle z_z \ldots z_n \rangle\$ are considered isomorphic if and only if there exists a bijection \$f\$ such that for all \$...
0
votes
0
answers
25
views
PathFinding.java: controller in MVC
Intro
This time, I need to get reviewed the controller class (from MVC pattern) responsible for user interaction with the 2D grid graph.
Code
...
0
votes
0
answers
23
views
PathFinding.java: SettingsPane class
Intro
I am still working on PathFinding.java. This time I need to get reviewed the class responsible for choosing the heuristic function, the finder implementation, just to mention a few of settings ...
4
votes
1
answer
137
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
36
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
326
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
618
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
178
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
158
views
Is this exception handling missing anything?
This is the code. I'm uncertain about the last block.
...
2
votes
0
answers
60
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
106
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
472
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
707
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
978
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
297
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
407
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
110
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
143
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
109
views
Code to add order orderitems and payment details
This is order, orderitems and payment linked by foreign key.
Controller:
...
4
votes
2
answers
183
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
65
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
45
views
Spring Boot RabbitMQ Publisher Configuration for Sending JSON Messages
The publisher class:
...
2
votes
3
answers
189
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
245
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
343
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
71
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
...