Originally posted by Tony Morris: What is the question here? Everyone (almost) knows it won't compile. You'd know that too if you tried. Are you asking why?
Why dont you post some mock questions here for the beta exam?
What is the question here? Everyone (almost) knows it won't compile. You'd know that too if you tried. Are you asking why?
You can post some mock question and let others to post the answers. As we know there is no mock exams for Java 1.5. This is the way to prepare for tiger exam.
Originally posted by Barry Gaunt: Actually it prints:
[Java, Added]
which is interesting because it implies that it is first converted to an array and then java.util.Arrays.toString is used to print it.
For %s
If the argument is null, then the result is "null". If the argument implements Formattable, then its formatTo method is invoked. Otherwise, the result is obtained by invoking the argument's toString() method.
So AbstracCollection's toString method is invoked.
Explaination. You are passing list and list1 both reference the same ArrayList, so you can add a String to list1, but you wouldn't be able to add a String to list. But since list is still pointing to the same ArrayList it will have the second added String in the ArrayList and print it.