Print 1–100

Print numbers from 1 to 100 using a loop.

BeginnerTopic: Module 3: Loop Programs
Back

Java Print 1–100 Program

This program helps you to learn the fundamental structure and syntax of Java programming.

Try This Code
public class Main {
    public static void main(String[] args) {
        for (int i = 1; i <= 100; i++) {
            System.out.print(i + " ");
        }
    }
}
Output
1 2 3 ... 100

Understanding Print 1–100

A simple for-loop that starts at 1 and increments i until it reaches 100.

Note: To write and run Java programs, you need to set up the local environment on your computer. Refer to the complete article Setting up Java Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your Java programs.

Table of Contents