13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

98Chapter 3An Experienced Programmer’s Introducti<strong>on</strong> to Java3.11EXERCISES1. Write a simple class with a main() method that prints out the argumentssupplied <strong>on</strong> the command line used to invoke it. First use a for loop todo this, then a while loop, then a do-while. What differences do younotice? Which do you find most amenable for this task?2. Modify the previous class to quit echoing its arguments should it encounteran argument of length 5. (You can tell the length of a Stringobject with the length() method, e.g., mystr.length().) Did you usebreak, or c<strong>on</strong>tinue, or some other mechanism?

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!