next up previous
Next: Example of for loop: Up: Unit 06 Previous: Observations on the for

Examples of for loops

The for loop is used mainly to realize definite loops.

Example: Print the numeric code of the characters from 15 to 85.

for (int i = 15; i <= 85; i++) {
  char c = (char)i;
  System.out.println("i = " + i + " -> c = " + c);
}


next up previous
Next: Example of for loop: Up: Unit 06 Previous: Observations on the for