| 10 | import java.util.stream.Stream; |
| 11 | |
| 12 | public class IntStreams { |
| 13 | |
| 14 | @Test |
| 15 | public void range() throws Exception { |
| 16 | System.out.println("with fori"); |
| 17 | for (int i = 0; i <= 10; i++) { |
| 18 | System.out.println(i); |
| 19 | } |
| 20 | System.out.println("with int stream exclusive"); |
| 21 | IntStream.range(0, 10).forEach(System.out::println); |
| 22 | |
| 23 | System.out.println("with int stream inclusive"); |
| 24 | IntStream.rangeClosed(0, 10).forEach(System.out::println); |
| 25 | } |
| 26 | |
| 27 | // Loop through people using IntStream |
| 28 | @Test |
| 29 | public void rangeIteratingLists() throws Exception { |
| 30 | List<Person> people = MockData.getPeople(); |
| 31 | IntStream.range(0, people.size()) |
| 32 | .forEach(index -> { |
| 33 | System.out.println(people.get(index)); |
| 34 | }); |
| 35 | } |
| 36 | |
| 37 | @Test |
| 38 | public void intStreamIterate() { |
| 39 | IntStream.iterate(0, value -> value + 1) |
| 40 | .limit(11) |
| 41 | .forEach(System.out::println); |
| 42 | } |
| 43 | } |
nothing calls this directly
no outgoing calls
no test coverage detected