Java Resources
Resources about programming in Java.
HOME
About
Java 8 Cheatsheet
Syntax for Java 8 lambda expressions...
4 MIN READ
Distinct elements in Java 8 streams
Finding the distinct elements of a Java stream is easy. We can use the `Stream#distinct` method...
2 MIN READ
Java 8 - effectively final variables
Effectively final variable is a variable that has not been explicitly marked as final, but it doesn't change its value (basically, an implicit constant). Effectively final variables can be referenced in lambdas, without the need to explicitly mark them as "final"...
2 MIN READ
Java 8 Lambda expressions
Let's create and run some `Runnable`! With Java 8, instead of using anonymous classes, we can use lambda expressions. The syntax `(params) -> statement` can be used to create an instance of Runnable by implementing its `run` method. This is possible only for interfaces that have only one abstract ...
4 MIN READ
Java 8 default methods
Starting from Java 8, a method which is defined in an interface can have a default implementation: For example...
3 MIN READ
Filter Java 8 stream
Let's filter a list of strings using Java 8 streams...
3 MIN READ
Java 8 stream map
Let's map a list of words using Java 8 streams...
3 MIN READ
Sort a collection with lambda comparator
With Java 8 we can use a lambda expression to implement a `Comparator` for sorting a collection...
3 MIN READ
Summary statistics on a Java 8 stream of numbers
Java 8 streams provide an easy way to calculate basic statistics on the values of a stream of numbers. We can use the `summaryStatistics` method to get the basic statistics: minimum, maximum, count, sum and average...
2 MIN READ