public class Main {
public static void main(String[] args) {
String[] arrayName = {"Turkey", "ABD", "England", "France", "Germany", "Netherlands"};
int i = 1;
int d = 0;
// Works as long as the value in it is true;
while(4 >= i) {
System.out.println("While Loop ----"+i);
i++;
}
// First, the do part works, then it checks.
do{
System.out.println("Do While Loop ----"+d);
d++;
}while(3>=d);
// for(Variable ; conditional statement ; operation)
for(int j = 0 ; 10>j ; j = j + 2) {
System.out.println("For Loop ----"+j);
}
// It reads and equals the entered values respectively.
// for(Variable : list, array, etc.)
for(String name : arrayName) {
System.out.println("For Each Loop ----"+name);
}
}
}
Output
Good Bye Everyone
Image Resource: https://www.edureka.co/blog/wp-content/uploads/2019/07/Loops-in-Java-Types-Edureka-1-364x300.png
0 Comments