FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java8-tutorial/src/com/winterbe/java8/Lambda1.java at master · lan13217/java8-tutorial · GitHub
lan13217
/
java8-tutorial
Public
forked from
winterbe/java8-tutorial
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
java8-tutorial
/
src
/
com
/
winterbe
/
java8
/
Lambda1.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (34 loc) · 1.24 KB
Breadcrumbs
java8-tutorial
/
src
/
com
/
winterbe
/
java8
/
Lambda1.java
Copy path
File metadata and controls
49 lines (34 loc) · 1.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package
com
.
winterbe
.
java8
;
import
java
.
util
.
Arrays
;
import
java
.
util
.
Collections
;
import
java
.
util
.
Comparator
;
import
java
.
util
.
List
;
import
java
.
util
.
Optional
;
/**
* @author Benjamin Winterberg
*/
public
class
Lambda1
{
public
static
void
main
(
String
[]
args
) {
List
<
String
>
names
=
Arrays
.
asList
(
"peter"
,
"anna"
,
"mike"
,
"xenia"
);
Collections
.
sort
(
names
,
new
Comparator
<
String
>() {
@
Override
public
int
compare
(
String
a
,
String
b
) {
return
b
.
compareTo
(
a
);
}
});
Collections
.
sort
(
names
, (
String
a
,
String
b
) -> {
return
b
.
compareTo
(
a
);
});
Collections
.
sort
(
names
, (
String
a
,
String
b
) ->
b
.
compareTo
(
a
));
Collections
.
sort
(
names
, (
a
,
b
) ->
b
.
compareTo
(
a
));
System
.
out
.
println
(
names
);
names
.
sort
(
Collections
.
reverseOrder
());
System
.
out
.
println
(
names
);
List
<
String
>
names2
=
Arrays
.
asList
(
"peter"
,
null
,
"anna"
,
"mike"
,
"xenia"
);
names2
.
sort
(
Comparator
.
nullsLast
(
String
::
compareTo
));
System
.
out
.
println
(
names2
);
List
<
String
>
names3
=
null
;
Optional
.
ofNullable
(
names3
).
ifPresent
(
list
->
list
.
sort
(
Comparator
.
naturalOrder
()));
System
.
out
.
println
(
names3
);
}
}
Back
|
FazBrowse Home
|
New Git URL