> public interface MyInterface {
> public void doSomething(Collection<Integer> collection);
[quoted text clipped - 11 lines]
> 1. MyClass doesn't implement the interface correctly since the method
> signatures are different.
As far as the JVM is concerned, both are methods called doSomething that
take a single Collection argument and return void. The signature is the
same.
The advantage of erasure is that if the base class had been updated to
use generics, the old derived class still works.
> 2. String can't be added to collection of Integer.
The static type is Collection, not Collection<Integer>.
When you compile the code, you should get a warning. Listen to compiler
warnings.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
Soren Kuula - 24 Aug 2006 20:41 GMT
As Thomas said, because of backwards compatibility issues, you will only
get a warning if you implement with a class that does not use generics.
If, on the other hand, you do
>> public class MyClass implements MyInterface {
>> public void doSomething(Collection <Object> collection) {
>> collection.add(new String());
>> }
>> }
you should get an error.
Søren