Use IntStream instead of int[] (#8)

Use an `IntStream` instead of an `int[]` array.
This commit is contained in:
Eric Deandrea
2019-11-15 05:42:41 -05:00
committed by James Falkner
parent b9adb3cd0e
commit 61c85adac3

View File

@@ -252,7 +252,7 @@ StarWarsService swService; // <1>
@Path("/swpeople") @Path("/swpeople")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public List<StarWarsPerson> getCharacters() { public List<StarWarsPerson> getCharacters() {
return Arrays.stream(new int[] {1, 2, 3, 4, 5}) // <2> return IntStream.range(1, 6) // <2>
.mapToObj(swService::getPerson) // <3> .mapToObj(swService::getPerson) // <3>
.collect(Collectors.toList()); // <4> .collect(Collectors.toList()); // <4>
} }