Stream(스트림) 스트림은 컬렉션에 관한 다양한 처리를 도와주는 API이다. 우선 다음 코드를 보자. animals.sort(Comparator.comparing(Animal::getAge)); for (Animal animal : animals) { if (animal.getAge() >= 10) { System.out.println(animal.getName()); } } 위 코드는 동물들을 나이순으로 정렬한 뒤 10살 이상인 동물들의 이름을 출력하고 있다. 이 간단한 코드를 스트림을 이용해서 다음과 같이 바꿀 수 있다. animals.stream() .sorted(Comparator.comparing(Animal::getAge)) .filter(animal -> animal.getAge() >=..