Last active
August 29, 2015 14:23
-
-
Save tk3fftk/bf8d10a8fed940cc6dec to your computer and use it in GitHub Desktop.
スモールスタートJava8 Stream API ref: http://qiita.com/tk3fftk/items/9faaabee4e88547bf3d3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(int i=0;i<100;i++){ | |
System.out.println(i); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IntStream intStream = IntStream.range(0, 100); | |
intStream.forEach(i -> { | |
System.out.println(i); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// List | |
List<String> list = Arrays.asList("a","b","c"); | |
for(String s: list){ | |
System.out.println(s); | |
} | |
// 配列 | |
String[] array = {"a", "b", "c"}; | |
for(String s: array){ | |
System.out.println(s); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// List | |
List<String> list = Arrays.asList("a","b","c"); | |
Stream<String> listStream = list.stream(); | |
listStream.forEach(s -> { | |
System.out.println(s); | |
}); | |
// 配列 | |
String[] array = {"a", "b", "c"}; | |
// どちらも出来るものは同じ | |
Stream<String> arrayStream01 = Arrays.stream(array); | |
Stream<String> arrayStream02 = Stream.of(array); | |
arrayStream01.forEach(s -> { | |
System.out.println(s); | |
}); | |
arrayStream02.forEach(s -> { | |
System.out.println(s); | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IntStream intStream = IntStream.range(0, 100).parallel(); | |
Stream<String> listStream = list.stream().parallel(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment