Skip to content

Commit

Permalink
Remove unused logger and reorder stream operations
Browse files Browse the repository at this point in the history
The logger declaration was removed as it was unused. Additionally, the `map` and `filter` operations in the stream pipeline were reordered for better readability and performance.
  • Loading branch information
kousen committed Sep 17, 2024
1 parent 42ccad5 commit 937c377
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/main/java/lazy/LazyStreams.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import java.util.stream.IntStream;

public class LazyStreams {
private static final Logger logger = Logger.getLogger(LazyStreams.class.getName());

public static int multByTwo(int n) {
System.out.printf("Inside multByTwo with arg %d on thread %s%n",
n, Thread.currentThread().getName());
Expand All @@ -30,8 +28,8 @@ public static void main(String[] args) {
// Demonstrate laziness using print statements
firstEvenDoubleDivBy3 = IntStream.rangeClosed(100, 2_000_000)
// .parallel()
.filter(LazyStreams::modByThree)
.map(LazyStreams::multByTwo)
.filter(LazyStreams::modByThree)
.findFirst().orElse(0);
System.out.printf("First even divisible by 3 is %d%n", firstEvenDoubleDivBy3);
}
Expand Down

0 comments on commit 937c377

Please sign in to comment.