質問編集履歴
1
質問内容の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
OCJP GOLDの学習をしております。
|
2
2
|
|
3
|
-
以下のコード
|
3
|
+
以下のコードで「Comparator.comparing」となっている理由が知りたいです。
|
4
4
|
|
5
5
|
ラムダ式に直すと、
|
6
6
|
Set<employee> set = new TreeSet<>((e1,e2) -> e1.getId() - e2.getId());
|
@@ -21,7 +21,7 @@
|
|
21
21
|
|
22
22
|
public static void main(String[] args) {
|
23
23
|
// TODO 自動生成されたメソッド・スタブ
|
24
|
-
Set<Employee> set = new TreeSet<>(
|
24
|
+
Set<Employee> set = new TreeSet<>(Comparator.comparing(Employee::getId));
|
25
25
|
set.add(new Employee(3,"John"));
|
26
26
|
set.add(new Employee(1,"Bill"));
|
27
27
|
set.add(new Employee(2,"Eric"));
|