Filling a list with a continuous range of shorts

Stack overflow.squite Since JDK8 does not provide a ShortStream class, how would you create a list of contiguous shorts?

I am looking for something like:

List<Short> range = ShortStream.range(0, 500).boxed().collect(Collectors.toList());

where the output contains a list of shorts, from 0 to 500 inclusive.

+1
source share
1 answer
 List<Short> range = IntStream.range(0, 500).mapToObj(i -> (short) i).collect(Collectors.toList()); 
+5
source

All Articles