Brian B wrote:
Well I got the answer...here it is
thanks for the help
Don't just 'I got the answer'... understand why that works.
You should be able to answer the following questions:
1. What is System? (A class, package, or something else?)
2. If a class, in what package is System located?
3. What is System.out, what args does it take, and what does it return?
4. What other methods besides println are available?
5. What types of variables are you passing to sout (for short), are any of them being caste? If so, how and why?
6. How could you have reduced the output from two lines to one line of code. And why would you want to? Why would you not want to?
7. Is the String literal mutable or immutable? How does the jvm handle String literals? Can you modify an immutable object?
8. How many different string concantenations does your main output line perform?
9. If it were in a loop iterating to say 1000, what should you do instead? And why? What is the relative cost in performance (both cpu and memory) of sout versus string concatenation versus string buffers.
And I won't even get started on unicode, locales, etc. Understanding is very (very, very, very) important - it is what seperates those who excel in the industry (and academia) from those who never get a job or just get by. It happens all the time - people who have been programming for 5+ years that take a serious spanking with the clue-by-four because they don't understand anything.