write a program to print first ten natural numbers in java

Solutions on MaxInterview for write a program to print first ten natural numbers in java by the best coders in the world

showing results for - "write a program to print first ten natural numbers in java"
Jessica
16 Jul 2018
1public class Main
2{
3public static void main(String[] args)
4{
5int number = 10, sum = 0;
6for(int i = 1; i <= number; ++i)
7{
8sum =sum + i;
9}
10System.out.println("Sum = " + sum);
11}
12}