To create an infinite loop using a for loop, you can simply omit the condition altogether. In fact, you can omit any (or all) the elements in the for loop's parentheses:
for(;;) {
n = sc.nextInt();
if (n % 10 == 0) {
break;
}
}
Having said that, the idiomatic way of creating an infinite loop is with a while loop. Note that for a while loop you can't just omit the condition, but must explxicity state a boolean expression that evaluates to true. The simplest way to do this, is, of course, to use the boolean literal true:
while (true) {
n = sc.nextInt();
if (n % 10 == 0) {
break;
}
}
However, for this usecase, IMHO it would be more readable to use a do-while loop. This way you're garunteed that the loop runs at least once, and the exit condition is part of the loop and easy (easier?) to notice:
do {
n = sc.nextInt();
} while (n % 10 != 0);
forloop. Just usewhile(true) {...}