Home » Java solved programs » Core java 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






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.