Skip to content

Latest commit

 

History

History
33 lines (22 loc) · 572 Bytes

Java8-in-action.md

File metadata and controls

33 lines (22 loc) · 572 Bytes

Java8 in action

lambda

stream

  • stream();

  • filter();

  • map();

  • flatMap() --combine all the streams into one

  • district();

  • count();

  • limit();

  • skip();

  • findAny(), findFirst()

  • anyMatch(), allMatch(), noneMatch()

  • Arrays.stream()

Stateless & Stateful

  • stateless: filter(), map()
  • stateful: sum(), count(), sort()

Collect

  • menu.stream().collect(groupingBy(Dish::getType))

Code example

  • Optional max = numbers.stream().reduce(Integer::max)
  • Stream lines = Files.lines(Paths.get("data.txt"), Charset.defaultCharset())