Java Program to Print First 10 Natural Numbers

Write a Java program to print first 10 natural numbers using for loop.

package NumPrograms;

public class First10NaturalNum1 {

	public static void main(String[] args) {
		
		System.out.println("The First 10 Natural Numbers are");
		for(int i = 1; i <= 10; i++) 
		{
			System.out.println(i);
		}
	}
}
Java Program to Print First 10 Natural Numbers

Java Program to print the first 10 natural numbers using a while loop.

package NumPrograms;

public class First10NaturalNum2 {

	public static void main(String[] args) {
		
		System.out.println("The First 10 Natural Numbers are");
		int i = 1;
		while(i <= 10) 
		{
			System.out.println(i);
			i++;
		}
	}
}
The First 10 Natural Numbers are
1
2
3
4
5
6
7
8
9
10

This Java example displays the first 10 natural numbers using the do while loop.

package NumPrograms;

public class First10NaturalNum3 {

	public static void main(String[] args) {
		
		System.out.println("The First 10 Natural Numbers are");
		int i = 1;
		do
		{
			System.out.println(i);

		} while(++i <= 10);
	}
}
The First 10 Natural Numbers are
1
2
3
4
5
6
7
8
9
10

Please refer to

  1. Print the First 10 Even Natural Numbers
  2. Print the First 10 Natural Numbers in Reverse
  3. Print the First 10 Odd Natural Numbers
  4. Java program to Print Even Numbers from 1 to N
  5. Java program to Print Odd Numbers from 1 to N
  6. Java program to Print Natural Numbers from 1 to N
  7. Java program to Print Natural Numbers in Reverse Order
  8. Java Program to Find the Sum of Natural Numbers from 1 to N