Skip to content

Commit

Permalink
collector
Browse files Browse the repository at this point in the history
  • Loading branch information
peas committed Mar 2, 2014
1 parent d511351 commit aba4cc4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/br/com/casadocodigo/java8/Capitulo9.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void main (String... args) {

for(Usuario u: usuarios) {
pontuacaoJ8
.computeIfAbsent(u.getPontos(), ArrayList::new)
.computeIfAbsent(u.getPontos(), user -> new ArrayList<>())
.add(u);
}

Expand All @@ -50,10 +50,14 @@ public static void main (String... args) {

Map<Boolean, Integer> pontuacaoPorTipo = usuarios
.stream()
.collect(Collectors.groupingBy(Usuario::isModerador,
.collect(Collectors.partitioningBy(u -> u.isModerador(),
Collectors.summingInt(Usuario::getPontos)));

System.out.println(pontuacaoPorTipo);

List<Integer> pontos = usuarios.stream()
.filter(u -> u.getPontos() > 100)
.reduce(new ArrayList<>(), (l1, l2) -> {l1.addAll(l2); return l1;});

}
}
Expand Down

0 comments on commit aba4cc4

Please sign in to comment.