New answers tagged java
0
votes
Rate-limited thread scheduler in Java
This code will work, but few suggestions :
Here we are using timer as well as executors, side by side, the problem here is that you are un-necessarily creating 2 threads, timer is just going to hand ...
1
vote
Implemented Sorting of Map by Value and then by Key in java
I think since you just need the winner, we can use the reduce operation post collecting the data in map, that will reduce the overall time complexity as well. Adding the modified version of the code ...
1
vote
Search/Query API cross parameter check
You could wrap the request parameters in a class and then implement a custom validator that checks the dates.
That way, your controller's code would be reduced to:
...
3
votes
Accepted
A vanilla Hibernate app (no Spring)
I suspect catching all Exceptions is bad practice (as opposed to catching specific exceptions).
It depends...
As long as you have the same reaction to all kinds of possible exceptions (just logging ...
0
votes
Send sorted, signed requests
The use of raw collection types is to me a bit of a code smell.
protected HashMap<String, Object> body(String[] keys, Object[] values) {
The declaration <...
1
vote
Send sorted, signed requests
Performance
At least by selecting the tag you ask for performance improvements.
As a rule of thump you should not optimize for performance unless you have measured the performance and verified, that ...
2
votes
Spring REST Endpoint for Saving a User Inquiry
Regarding the mapper
public final class QuestionMapper {
public static Question toEntity(QuestionRequestDto dto) {
...
}
}
The way the mapper is ...
2
votes
The Matrix Winds In
We see multiple code stanzas that resemble:
currentX--;
currentY++;
which seems tedious.
Define a vector of four (delta_x, delta_y) pairs:
<...
0
votes
Quick Sort Done Lucidly
Sort Generic Lists
It’s even more in the spirit of the algorithm, as I see it, to sort a List of a generic type by a comparator. This is an interface that ArrayList implements.
In particular, that ...
2
votes
Quick Sort Done Lucidly
To cover a few points that are not mentioned in the other two answers:
Choice of loops
Let's take a look at this while-loop:
...
4
votes
String Permutation Implemention
The sources of inspiration aren't really up for review, but they have a couple of things in common:
They print the permutations, instead of storing them in a list. They could be adapted though.
They ...
1
vote
Identifying indices of non-delimited characters in a string, supporting greater than 1 length of delimiters
Looking at the code, I can't easily tell its purpose.
Java code exists in files and classes, blocks, functions, methods, and lambdas.
With the exception of blocks, ...
6
votes
Quick Sort Done Lucidly
Considering that the very name of the algorithm references speed, I think any approach that ignores important performance factors is very much against the "spirit" of the algorithm. As such, ...
7
votes
Quick Sort Done Lucidly
The "spirit" of the algorithm is a subjective view, therefore it cannot be used as solid criteria for review. I will thus ignore that aspect completely.
First and foremost, the algorithm ...
2
votes
Accepted
Interest/Discount rate and loan calculator java
First of all, I'm coming from a C / C++ / C# and Haskell background and am not too familiar with Java.
However, the main focus of this review are general programming techniques that will help you ...
2
votes
Accepted
Optimize Island Counter program
import java.util.*;
...
Scanner sc = new Scanner(inputfile);
It turns out the * wildcard refers to
this class.
...
Top 50 recent answers are included
Related Tags
java × 10880performance × 1276
algorithm × 1271
beginner × 1034
object-oriented × 714
android × 698
strings × 638
programming-challenge × 633
array × 498
multithreading × 455
swing × 413
game × 409
interview-questions × 354
design-patterns × 300
tree × 281
linked-list × 263
sorting × 262
spring × 220
recursion × 219
unit-testing × 198
parsing × 178
homework × 176
concurrency × 174
comparative-review × 172
hash-map × 170