Skip to content

Commit 4219619

Browse files
update CollectorsDemo.java
1 parent 7b9980c commit 4219619

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/FDynamic/Stream/CollectorsDemo.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public static void main(String[] args) {
1616
new Person("bbb", 19, new BigDecimal(124))
1717
);
1818
groupBy(personList);
19+
partionBy(personList);
1920
}
2021

2122
/**
@@ -28,4 +29,14 @@ public static void groupBy(List<Person> personList){
2829
System.out.println(map);
2930
}
3031

32+
/**
33+
* 根据人员的name是否是aaa来进行区分
34+
* @param personList
35+
*/
36+
public static void partionBy(List<Person> personList){
37+
Map<Boolean, List<Person>> map=personList.stream()
38+
.collect(Collectors.partitioningBy(person -> "aaa".equals(person.getName())));
39+
System.out.println(map);
40+
}
41+
3142
}

0 commit comments

Comments
 (0)