The java program that calculates the sum of the squares of all numbers from 1 to 10 using the IntStream class from the Java Stream API. Here's an explanation of the code:
import java.util.stream.IntStream; public class SumOfSquareNumber { public static void main(String[] args) { int sum_squares = IntStream.rangeClosed(1, 10).map(n -> n * n).sum(); System.out.println("Sum of Squares of all numbers from 1 to 10 : " + sum_squares); } }
Sum of Squares of all numbers from 1 to 10 : 385
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions