Skip to content
This repository was archived by the owner on Feb 10, 2021. It is now read-only.

Commit 5bfc9e5

Browse files
authored
Update readme.md
- added method reference example
1 parent edd19dd commit 5bfc9e5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lambdas/readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ It can be easily simplified using lambda expression:
3030
```java
3131
accounts.sort((a1, a2) -> a1.getFirstName().compareTo(a2.getFirstName()));
3232
```
33+
In case you are calling some existing method inside the lambda, you can reference that method instead of acctually calling it. This technique is called *Method Reference*. Combining it with usefull default method `comparing()` it can help you to simplify the code even more:
34+
```java
35+
accounts.sort(comparing(Account::getFirstName));
36+
```

0 commit comments

Comments
 (0)