Java Loop Statements Java Loop Statements
Java Loop Statements Java Loop Statements
Java Loop Statements Java Loop Statements
STATEMENTS
Introduction, Java Loops
class Main {
public static void main(String[] args) {
int n = 5;
// for loop
for (int i = 1; i <= n; ++i) {
System.out.println("Java is fun");
}
}
}
While Loops
class Main {
public static void main(String[] args) {
// declare variables
int i = 1, n = 5;
Syntax:
do {
// body of loop
} while(textExpression);
Do-While Looops
Exmaple
import java.util.Scanner;
class Main {
public static void main(String[] args) {
int i = 1, n = 5;
VENKITT SURESH
venkittsuresh@gmail.com