Java Reference
In-Depth Information
3.11
E XERCISES
1. Write a simple class with a main() method that prints out the arguments
supplied on the command line used to invoke it. First use a for loop to
do this, then a while loop, then a do-while . What differences do you
notice? Which do you find most amenable for this task?
2. Modify the previous class to quit echoing its arguments should it en-
counter an argument of length 5. (You can tell the length of a String
object with the length() method, e.g., mystr.length() .) Did you use
break , or continue , or some other mechanism?
Search WWH ::




Custom Search