Text Size
Thursday, April 15, 2021


Simple Loops in Java

For Loops:

for (starting value; ending condition; iteration)
A for loop has three basic sections:

  1. The starting value on the loop's counter.
  2. The ending condition of the loop (what number will the loop stop at).
  3. The iteration: What will the counter count up or down by.

For example:
for (int count=1; count<100; count++)

This loop will start at count = 1. As long as count is less than (<) 100 the loop will continue to function. Count will add one to itself: count++.

While Loops:

while (condition)

A while loop is simpler than a for loop. A while loop will continue to loop as long as the condition is true.

For example:
while (int x != 10)

This loop will continue as long as x is not ten. If x's value is ten when the loop tests the condition the loop will stop.



Parent Category: ICS4C
Comment (0) Hits: 3029


Hardware / Software / Operating System

  1. Program Language Scavenger Hunt
  2. Parts of the Computer Presentation
  3. Network / Home Computer Security

Problem Solving

  1. Take Home Test

The Computer and Society


Major Projects

  1. Computer Interests Presentation
  2. Culminating Activity
Parent Category: ICS4C
Comment (0) Hits: 3097