import java.util.stream.IntStream;
public class FromIntRangeExample {
public static int sum;
public static void main(String[] args) {
IntStream stream = IntStream.rangeClosed(1, 1000);//1~1000까지의 합 구하기
stream.forEach(a->sum+=a);
System.out.println("총합:"+sum);
}
}
``
총합:500500