Example
// use while to print first 10 powers of 2
final static int LIMIT = 10;
int count = 1, power_of_two = 1;
while (count <= LIMIT) {
power_of_two = power_of_two * 2;
System.out.println(power_of_two);
count = count + 1;
}
Previous slide
Back to first slide
View graphic version