Bruce Eckel's Thinking in Java Contents | Prev | Next

Exercises

  1. Write a program that prints values from one to 100.
  2. Modify Exercise 1 so that the program exits by using the break keyword at value 47. Try using return instead.
  3. Create a switch statement that prints a message for each case, and put the switch inside a for loop that tries each case. Put a break after each case and test it, then remove the breaks and see what happens.

o

Contents | Prev | Next