Section 3.11. Exercises


3.11. Exercises

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 encounter 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?



    Java Application Development with Linux
    Java Application Development on Linux
    ISBN: 013143697X
    EAN: 2147483647
    Year: 2004
    Pages: 292

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net