posted 12 years ago
The generic set with <?> won't let you add anything except null as a rule of the compiler to make your collection type safe.
During compilation time, the set means it refers to a collection that contains a type of object as specified on the right hand side.
During compilation time, the compiler does not know what set will contain. It can be Object, Animal, Cat, Dog....
For example, you may want to add this to the class in the future:
Again during compilation time, set.add( ...) will not compile because the compiler does not know what set will contain. The compiler won't let you put a wrong type of object to set.