Skip to content

Instantly share code, notes, and snippets.

@LeoHeo
Last active March 3, 2018 02:51
Show Gist options
  • Save LeoHeo/a6132c574cddd85038b8d48cfda07dc3 to your computer and use it in GitHub Desktop.
Save LeoHeo/a6132c574cddd85038b8d48cfda07dc3 to your computer and use it in GitHub Desktop.
class StreamExamples {
public static void main(String[] args) {
final List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
numbers.stream()
.filter(number -> number > 3) // Intermediate Operation Method -> 즉시 연산을 안하고 기다린다.
.map(number -> number * 2) // Intermedidate Operation Method -> 즉시 연산을 안하고 기다린다.
.filter(number -> number > 10) // Intermedate Operation Method -> 즉시 연산을 안하고 기다린다.
.findFirst() // Terminal Operaion Method -> filter, map연산들을 한다.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment