Henry Wong wrote:
But it comes with a price, since your method must work with any type, and you don't know the generic type (except to say that it extends container). How can you add anything? You can only add items that satisfies all possible types supported by your method, and that is only null.
Henry
3=Aaron
2=Ala
1=Bio
4=Aaahh
When solving searching and sorting questions, two big gotchas are:
1. ... [this part is clear]
2. Using a Comparator in either the sort or the search, but not both.
String s = new String ("abc");
In this case, because we used the new keyword, Java will create a new String object in normal (nonpool) memory, and s will refer to it. In addition, the literal "abc" will be placed in the pool.