Java Do-While-Loop
Bei Do-While-Loop wird die Anweisung mindestens 1 mal wiederholt.
Es folgt die Denkweise von While-Loop
public class Main {
public static void main(String[] args) {
boolean condition = true;
int counter = 0;
do {
System.out.println("Die Schleife läuft: " + counter);
counter++;
if (counter >= 5) {
condition = false; // Schleife beenden, wenn counter >= 5
}
} while (condition);
}
}