The following code example demonstrates how to Display Integers from 1 to 10 in Java.
In order to repeat a number of statements in the code, we use loops. Basically, java provides us while loop, do..while loop, and the for loop. The following program displays the integers in the range 1 to 10 separated by tabs.
public class Exercise10
{
public static void main(String[] args) {
for(int i=1;i<=10;i++)
{
System.out.print(i+"\t");
}
System.out.println();
}
}
Output