To save people constantly looking up how to do loops in the lecture notes, here’s a simple example that prints the numbers 0 to 4 inclusive.
As a for loop:
for(int i=0; i<5; i++) {
System.out.println(i);
}
As a while loop:
int i=0;
while(i<5) {
System.out.println(i);
i++;
}
No Comments so far ↓
There are no comments yet...Kick things off by filling out the form below.
You must log in to post a comment.