Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
5 votes
2 answers
529 views

Java - Converting a skip list to the ASCII art

Intro This post won't present the actual mechanics of the skip list. Instead, all I got here is the facility for converting skip lists to funky ASCII art. For example, the unit test prints: ...
coderodde's user avatar
  • 28.6k
-2 votes
1 answer
91 views

How can I reduce my code in time complexity?

My friends in the same project told me that I needed to improve this code's complexty, so I tried but couldn't figure out how to do more.. They also said that I needed to change my coding style and ...
김형찬's user avatar
3 votes
1 answer
198 views

Leetcode: Number of Islands - BFS (Queue vs Recursion)

I was playing around with leetcode's Number of Islands. As per the challenge's description: Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the ...
ccot's user avatar
  • 341
3 votes
1 answer
91 views

In Java, replace for loop with condition with lambdas [closed]

I want to replace a for loop with a break/return condition inside with a lambda. I think I have a good replacement, but I want ...
Oscar Besga Panel's user avatar
0 votes
0 answers
55 views

Securing microservices with Spring Security JWT

I would like to build a RESTful microservices architecture where each microservice acts as a resource server. Additionally, there will be an authorization server responsible only for user registration,...
yaroslav96's user avatar
2 votes
1 answer
37 views

Swing calculator with GUI Designer

I made this calculator during the weekends as a way to practice using IntelliJ's GUI Designer. It's used extensively in my new employer's Swing projects, but I hadn't heard of it before. As a ...
Sergey's user avatar
  • 561
5 votes
0 answers
87 views

Dial's heap in Java for integer priority queues

(The entire project is here.) Intro I have this priority queue data structure for non-negative integer priority keys. I recall that it is called Dial's heap. Code Implementation ...
coderodde's user avatar
  • 28.6k
1 vote
0 answers
43 views

A machine learning model for predicting bit strings in Java

I have this GitHub repository (BitPredictor.java). Basically, I tried to harness a machine learning model for predicting bit strings. I have implemented it to the best of my understanding and have ...
coderodde's user avatar
  • 28.6k
7 votes
3 answers
166 views

Euler - Largest Palindrome Product in Java

Having been going over the documentation, learning more of the subtleties of Java. I am now going over some basic Project-Euler solution code I wrote a little while back. Hoping I can pick up some ...
tijko's user avatar
  • 710
9 votes
2 answers
559 views

Advent of code 2023 day 5 in Java: mapping integer ranges to new integer ranges

Context I'll be passing an interview coding test in java soon. I am experienced with other programming languages but am very unfamiliar with Java. I am looking for critiques of the coding style much ...
Stef's user avatar
  • 282
2 votes
0 answers
52 views

Classes for Config and logical operators

I have a spring cloud gateway application with this yml structure for request validation: ...
Q2Dev's user avatar
  • 21
2 votes
1 answer
69 views

Research program for examining array list arithmetic contractions

Introduction Suppose we have a dynamic table \$T\$. Let \$\vert T \vert\$ denote the number of elements currently stored in \$T\$, and \$\vert \vert T \vert \vert\$ denote the capacity of \$T\$. Also, ...
coderodde's user avatar
  • 28.6k
3 votes
1 answer
164 views

Snail matrix in Java - version III (generalizing)

Once again, in the previous version, Alexander Ivanchenko helped me with his awesome answer. Now, I have improved the toString() and, also, generalized the class ...
coderodde's user avatar
  • 28.6k
4 votes
1 answer
321 views

Snail matrix in Java - version II

(This post is the continuation of Snail matrix in Java. Also, this post has an continuation.) As previously, a snail matrix is any square matrix \$M_n = \mathbb{N}^{n \times n}\$ with cell elements ...
coderodde's user avatar
  • 28.6k
6 votes
2 answers
862 views

Snail matrix in Java

(This post has an continuation: Snail matrix in Java - version II.) Inspired by this post, I decided to solve that problem in Java. The idea is to decide on an \$n \in \mathbb{N}\$, create a square ...
coderodde's user avatar
  • 28.6k
5 votes
2 answers
238 views

Simple Java Command-line Checkers Game

I was working on a checkers game for a college project. After I did a sprint to finish it, I want to improve the movement logic. Right now, it is housed within the ...
ViceroyFaust's user avatar
4 votes
4 answers
1k views

Stack - implementation in Java

I implemented a stack data structure without using any libraries or Java API code. ...
Mardson Diego's user avatar
5 votes
3 answers
634 views

Password checker using Decorator Pattern

I'm currently trying a Password checker for password in Decorator Pattern, which will point out what the current password missing to be a strong password (my example will check for 8 characters, at ...
DEF ABC's user avatar
  • 53
5 votes
1 answer
117 views

Creating random music covers using Conways Game of Life algorithm

(A sample cover art follows.) I'm currently working on replacing all the covers of my music files to have a unified theme, and I've started this project in Java to refresh my knowledge after a gap of ...
Zipity's user avatar
  • 51
6 votes
2 answers
793 views

A word counter (wc) utility clone

I was practicing Java by building some of the challenges on this website: https://codingchallenges.fyi/challenges/challenge-wc/ I've built a word counter clone and I wanted to know if my solution is ...
Reacher's user avatar
  • 63
5 votes
1 answer
325 views

Leetcode: Largest Number

I was trying out leetcode's Largest Number. As per the challenge's description: Given a list of non-negative integers nums, arrange them such that they form the largest number and return it. Since ...
ccot's user avatar
  • 341
1 vote
1 answer
63 views

Rate limiting WebFilter

It's a simple WebFilter for limiting RPS from one of my projects. There's only one OOB BucketResolver that has one shared bucket ...
Sergey's user avatar
  • 561
7 votes
3 answers
1k views

Is this a correct implementation of Comparator?

I have a class, Word, that has a String representing a word and an Enum representing the difficulty of the word. Then I have another class, Vocab, that has an ArrayList of Word-objects. I want to sort ...
Alexander Jonsson's user avatar
4 votes
3 answers
249 views

Given two sparse vectors, compute their dot product

Problem Statement: Given two sparse vectors, compute their dot product. Implement class SparseVector: SparseVector(nums) Initializes the object with the vector nums dotProduct(vec) Compute the dot ...
Pankaj Kumar's user avatar
3 votes
1 answer
209 views

A library management system

Following is my code for a library management system. I am pretty new to OOD and trying to learn it. I am specially looking for ways where any design patterns can be useful here. I tried to make ...
Pankaj Kumar's user avatar
0 votes
0 answers
48 views

WikiGameKillerFX.java - a JavaFX GUI program for solving the Wiki Game instances

I have this GitHub repository. In Wiki Game, players agree on random source and target articles, and attempt to navigate from the source to the target using least number of links. If there is a tie, ...
coderodde's user avatar
  • 28.6k
1 vote
0 answers
63 views

WikiGameKiller.java - a program for solving Wiki game instances

Intro I have this GitHub repository. Basically, it is a command-line utility for searching automatically for shortest link paths in the Wikipedia article graph. The game in question is sometimes ...
coderodde's user avatar
  • 28.6k
2 votes
2 answers
512 views

Using java streams to handle incoming API requests

I am using the java stream API to handle incoming requests my employee service. A few questions I had are: Does using the streams API in the way I'm using it below affect the performance of the ...
Brandon Bryan's user avatar
4 votes
1 answer
85 views

Java classes for downloading all in-coming/out-going links of an article in the Wikipedia article graph

(The entire project is in GitHub.) Introduction This project provides facilities for generating in-coming or out-going links in a given Wikipedia page. Code ...
coderodde's user avatar
  • 28.6k
0 votes
0 answers
32 views

Thread pooled bidirectional breadth-first search in Java for graphs with slow node expansion - part II/II: fluent APIs for builders

Intro This post follows Thread pooled bidirectional breadth-first search in Java for graphs with slow node expansion - part I/II: the algorithm. Basically, these are build patterns leveraging fluent ...
coderodde's user avatar
  • 28.6k
0 votes
0 answers
41 views

Thread pooled bidirectional breadth-first search in Java for graphs with slow node expansion - part I/II: the algorithm

(This post has part II/II.) Intro This time, I have this GitHub repository. The idea is that if the graph node expansion is slow (for example, in the case where you ask a web server to return some ...
coderodde's user avatar
  • 28.6k
1 vote
2 answers
93 views

simple Text Table utility

A small utility to print data in an ascii table TextTable ...
Martin Frank's user avatar
  • 2,838
5 votes
3 answers
94 views

Time based cache for single element

The container should be thread safe and provide lazy load of data, and cache the data for set period of time. ...
trolkura's user avatar
  • 151
1 vote
0 answers
29 views

User Management System: a web app for management of user records (Part I: Backend)

Note: It's Part I of the User Management System project, focused on the backend. See Part II here. I made this app about a year ago. I was a fledgling developer who didn't have a lot of clues to what ...
Sergey's user avatar
  • 561
4 votes
2 answers
108 views

(Another) text formatting method with word wrapping in Java

Please take a look at my code for (simply) formatting/wrapping a text. Is there something to improve? Here are the properties the method should have: (updated) Every space character (i.e. ...
Tobias Grothe's user avatar
0 votes
0 answers
31 views

Efficient least-significant digit (LSD) radix sort for int and long keys in Java - iteration II

This post elaborates on Efficient least-significant digit (LSD) radix sort for int keys in Java. This time, I made mild corrections to my code and provided the radix sort for ...
coderodde's user avatar
  • 28.6k
0 votes
0 answers
36 views

ParamInitializer framework: automatic provision of expected request parameters by Spring Cloud Gateway

I continue to share portions of my Dynamic Gateway project This time, I want to publish the types relating to its "parameter initializing" functionality. The idea is simple: if my gateway ...
Sergey's user avatar
  • 561
0 votes
0 answers
41 views

Retrieving resources of JWT-authenticated user Spring Boot Java

I have a Java Spring Boot Rest-API which is authenticated using JWT-tokens. Currently the API only contains Users and CashflowCategories. An user can have many CashflowCategories. When the user makes ...
O'Niel's user avatar
  • 197
3 votes
1 answer
125 views

Efficient least-significant digit (LSD) radix sort for int keys in Java

(This post has a continuation post.) This one is my attempt at LSD radix sort: Code com.github.coderodde.util.LSDRadixsort.java: ...
coderodde's user avatar
  • 28.6k
0 votes
0 answers
37 views

Scaffolding through my own language (Rapid Application Development)

I'm developing a webapp where some parts that repeat, so I made source code to generate source code. I had a lot of fun using Spring-Roo and Grails in the past but was sad that the difference between ...
Grim's user avatar
  • 612
2 votes
1 answer
44 views

Any possible issues with my approach to Access Management where I'm associating the list of Departments with the User class?

I have a spring boot project with JWT being used for Spring Security. I want to implement Access Management in my project and I'm using this approach. In my project, whenever a user is created, a list ...
Joe's user avatar
  • 23
1 vote
1 answer
73 views

Multiple Producer and Multiple Consumer Implementation Using Locks and Semaphore

This solution has a total of four classes. Main.java: Class with main method. Execution starts here. ...
vvs14's user avatar
  • 111
3 votes
1 answer
303 views

Implementation of java.util.stream.Stream (and friends) that reads lines from the internet without requiring you to manage the resources

This streams lines of information over the internet using BufferedReader::lines. However, what makes this special (and thus, extraordinarily complicated imo) is ...
davidalayachew's user avatar
4 votes
2 answers
487 views

Leetcode: Steps to Make Array Non-decreasing

I was trying out leetcode's Steps to Make Array Non-decreasing As per the challenge's description: You are given a 0-indexed integer array nums. In one step, remove all elements nums[i] where nums[i ...
ccot's user avatar
  • 341
4 votes
2 answers
85 views

Choosing Between Field Injections and Constructor Injections for Modular Java Applications with Spring Boot

I'm six months into a Java training program and have developed a Spring Boot application, adhering to Java's separation of concerns principle. I've organized my application with distinct sections for ...
Kerem Tazedal's user avatar
1 vote
1 answer
62 views

An API fetcher class - afraid of overengineering class

I'd like to ask you for a code review of this class. I'm quite new to Java and I'm afraid I have way overengineered this class. It's goal is only to fetch a specified data from given API, whose link ...
Piotr's user avatar
  • 13
1 vote
3 answers
109 views

Find min sum for indices to match equation

I want to reduce time complexity of my code: I have an array of integers arr say [1, 2, 3, 6, 67] I have an equation : a*x+b*y=z, I can use the array values in this ...
learner's user avatar
  • 149
1 vote
0 answers
79 views

Skip list -based Map in Java

Now I have this result. Code com.github.coderodde.util.SkipListMap.java: ...
coderodde's user avatar
  • 28.6k
9 votes
4 answers
2k views

Leetcode : First Missing Positive

I was trying out leetcode's first missing positive. As per the challenge's description: Given an unsorted integer array nums, return the smallest missing positive integer. You must implement an ...
ccot's user avatar
  • 341
2 votes
2 answers
107 views

Simple authentication server

Here's a simple authentication server. It's pretty basic but has the core functionality of sign-up and log-in handling. Your best bet is to simply run the ...
Sergey's user avatar
  • 561

1
2 3 4 5
218