Skip to content

Instantly share code, notes, and snippets.

View amoawad's full-sized avatar

Ahmed Moawad amoawad

View GitHub Profile
@amoawad
amoawad / Java8FeaturesDemo.java
Last active March 28, 2021 15:36
A brief introduction to some of the basic Java 8 new features.
/* Class definition ommitted */
public void run(){
List<Integer> list = Arrays.asList(5, 9, -1, 60, 10, 2, 9);
// region <lambdas> ---------------------------------------------------------------------------┐
list.sort ((a, b) -> b - a);
list.forEach(i -> System.out.print(i + " ")); // output: 60 10 9 9 5 2 -1
// ┌-----------> Note the empty parenthesis, this lambda has no input