for Loop

Lesson Progress
0% Complete

This program will print numbers from 1 to 10.

syntax: for(start, end,step)

public class ForLoop {
	public static void main(String[] args) {
		for (int i = 1; i <= 10; i++) {
			System.out.println(i);
		}
	}
}

Example: Multiplication Table of 3

public class ForLoop_Example1 {

	public static void main(String[] args) {
		for (int i = 1; i <= 10; i++) {
			System.out.print(i * 3 + " ");
		}
	}

}