COMP1400 – Programming for Designers

Class announcements for Programming for Designers

COMP1400 – Programming for Designers random header image

Loops

Posted by on October 16th, 2011 · Uncategorized

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.