Last active
February 22, 2019 02:21
-
-
Save ariesmcrae/53da8281eba314de15159552a1efe949 to your computer and use it in GitHub Desktop.
Arrays.asList vs Stream.Of
This file contains hidden or 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
| package com.ariesmcrae.streams; | |
| import java.util.Arrays; | |
| import java.util.List; | |
| import java.util.stream.Stream; | |
| public class MainBuldingStreams { | |
| public static void main(String[] args) { | |
| // first way | |
| List<Integer> ints = Arrays.asList(0, 1, 2, 3, 4); | |
| Stream<Integer> stream = ints.stream(); | |
| stream.forEach(System.out::print); | |
| System.out.println("\n"); | |
| // second way | |
| stream = Stream.of(0, 1, 2, 3, 4, 5); | |
| stream.forEach(System.out::print); | |
| } | |
| /* | |
| 01234 | |
| 012345 | |
| */ | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment