The infinite for loop is rather similar to the standard infinite while loop. The while loop uses true as an argument and will continue to operate forever because the argument is true and will not change. Similarly the infinite for loop works almost the exact same way. It uses true as it’s boolean expression and just leaves the initialization as null and the stepper as null. It looks like this.
1 2 3 4 5 6 7 8 9 10 | //creating an infinite loop by making the boolean value true and the other expressions null. for(; true ;){ System.out.println("Test"); } //similar to this there is the while loop. while(true){ //The expression just needs to be true. //for example, it could be while(5 > 2){... } |