public class Main {
public static void main(String[] args) {
int[] a = java.util.stream.IntStream.rangeClosed(1, 100).toArray();
int sum = java.util.Arrays.stream(a).sum();
System.out.println(sum);
}
}
//5050
-[Java --java Add from 1 to 100 | teratail] (https://teratail.com/questions/180348)
Read Java 8 reference books.
I want to be familiar with streams.
Recommended Posts