für und während Schleifen Java
for (let i = 1; i <=5; ++i) {
// body of loop
}
SAMER SAEID
for (let i = 1; i <=5; ++i) {
// body of loop
}
do {
// code block to be executed
}
while (condition);
class Main {
public static void main(String args[]){
int i=1;
while(i<10){
System.out.println(i);
i++;
}
}
}
// this will print 1 to 10.
int ctr = 1;
while(ctr <= 10)
{
System.out.println(ctr); // print ctr value
ctr++; // increment ctr value by 1
}
while (testExpression) {
// body of loop
}
while(condition) {
}