Java generics code compiles with javac, fails with Eclipse Helios

后端 未结 8 1631
挽巷
挽巷 2020-12-16 02:53

I have the following test class that uses generics to overload a method. It works when compiled with javac and fails to compile in Eclipse Helios. My java version is 1.6.0_2

8条回答
  •  北海茫月
    2020-12-16 03:37

    A point to keep in mind is that (all?, certainly some as for instance the NetBeans editor does this) static code analysis tools do not consider return type or modifiers (private/public etc.) as part of the method signature.

    If that is the case, then with the aid of type erasure both getFirst methods would get the signature getFirst(java.util.ArrayList) and hence trigger a name clash...

提交回复
热议问题