Home »
Java Programs »
Core Java Example Programs
Java program to print numbers from 1 to 10 using for loop
This is an Example of java for loop - In this java program, we are going to print numbers from 1 to 10 using for loop.
Submitted by Chandra Shekhar, on March 09, 2018
To print numbers from 1 to 10, we need to run a loop (we are using for loop here), logic to print numbers:
- In this program, we included a package named ‘IncludeHelp’ which is on my system, you can either remove it or include your package name, in which program’s source code is saved.
- Running loop from 1 to 10 and printing the numbers using System.out.println() that will print numbers in new line.
Example:
Numbers from 1 to 10
1
2
3
4
5
6
7
8
9
10
Program to print the number from 1 to 10 using for loop in java
package IncludeHelp;
public class Print_1_To_10_UsingFor
{
public static void main(String[] args)
{
//print the result
System.out.println("Output is : ");
//loop to print 1 to 10.
for(int i = 1; i <= 10; i++)
{
System.out.println(i);
}
}
}
Output
Output is :
1
2
3
4
5
6
7
8
9
10
Core Java Example Programs »