Please see below code for while loop now –
package practice;
public class WhileLoop {
public static void main(String[] args) {
int i = 0;
while (i < 5) {
System.out.println(i);
i++;
}
}
}
Explaination
0
1
2
3
4