posted 21 years ago
For a detailed description of anonymous (nameless) objects, read Thinking in Java. I've seen them used for very small event listeners.
The main difference between collections and templates is typesafty. What you get out of a collection is of type object, and you have to perform a cast to work with it. Containers in C++, wich are based on templates, are instantiated with a type, and you get an object of that type out of them.
Again, for details read the book by Bruce Eckel. There's a free download availabel at bruceeckel.com, and it's really great.
BTW, Java 1.5 will have a feature called generics, wich is very much the same as templates.
[ April 07, 2004: Message edited by: Tobias Hess ]