Java Tutorials

BiFunction & Supplier (Java 8)

BiFunction<T, U, R> What: A functional interface that takes two inputs and returns one result. Signature: R apply(T t, U u) Extras: default <V> BiFunction<T, U, V> andThen(Function<? super R,...

BiFunction & Supplier (Java 8)

BiFunction<T, U, R> What: A functional interface that takes two inputs and returns one result. Signature: R apply(T t, U u) Extras: default <V> BiFunction<T, U, V> andThen(Function<? super R,...

Parallel Streams in Java – Explanation & Advant...

Β  AΒ parallel stream splits the data source into chunks and processes them in parallel using the Fork/Join framework (the common pool). It’s a drop-in alternative to sequential streams for CPU-bound...

Parallel Streams in Java – Explanation & Advant...

Β  AΒ parallel stream splits the data source into chunks and processes them in parallel using the Fork/Join framework (the common pool). It’s a drop-in alternative to sequential streams for CPU-bound...

How to avoid OutOfMemory error in java

Avoiding OutOfMemoryError in Java involves both proactive memory management in your code and proper configuration of the Java Virtual Machine (JVM). 1. Code-Level Memory Management: Prevent Memory Leaks: Close Resources:...

How to avoid OutOfMemory error in java

Avoiding OutOfMemoryError in Java involves both proactive memory management in your code and proper configuration of the Java Virtual Machine (JVM). 1. Code-Level Memory Management: Prevent Memory Leaks: Close Resources:...

Pass by value or Pass by Reference?

Short answer: Java is always pass-by-value. What trips people up is what the β€œvalue” is: For primitives (int, double, boolean, …): the value is the actual number/bit pattern. You get...

Pass by value or Pass by Reference?

Short answer: Java is always pass-by-value. What trips people up is what the β€œvalue” is: For primitives (int, double, boolean, …): the value is the actual number/bit pattern. You get...

What is Lombok?

Lombok is a compile-time code generator for Java that uses annotations to remove boilerplate (getters, setters, constructors, builders, equals/hashCode, toString, loggers, etc.). It works via annotation processing: your IDE/build runs...

What is Lombok?

Lombok is a compile-time code generator for Java that uses annotations to remove boilerplate (getters, setters, constructors, builders, equals/hashCode, toString, loggers, etc.). It works via annotation processing: your IDE/build runs...

Comparator vs Comparable

TL;DR Comparable β†’ put the natural order inside the class (one order). Comparator β†’ define external strategies outside the class (many orders). Core differences Package & method Comparable<T> (java.lang) β†’...

Comparator vs Comparable

TL;DR Comparable β†’ put the natural order inside the class (one order). Comparator β†’ define external strategies outside the class (many orders). Core differences Package & method Comparable<T> (java.lang) β†’...