Skip to content

Commit 6afcb08

Browse files
committed
Use List.sort instead of Collections.sort
1 parent 7fa21e2 commit 6afcb08

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Collections.sort(names, (String a, String b) -> b.compareTo(a));
108108
For one line method bodies you can skip both the braces `{}` and the `return` keyword. But it gets even more shorter:
109109

110110
```java
111-
Collections.sort(names, (a, b) -> b.compareTo(a));
111+
names.sort((a, b) -> b.compareTo(a));
112112
```
113113

114114
The java compiler is aware of the parameter types so you can skip them as well. Let's dive deeper into how lambda expressions can be used in the wild.

0 commit comments

Comments
 (0)