Duplicate :
|
|
Relates :
|
|
Relates :
|
The following illustrates that the binary compatibility rules conflict with generics. The method resolved at compile time and at runtime are different, resulting in a runtime call to the wrong method. Date: Wed, 25 Feb 2004 14:15:59 -0800 From: <###@###.###> Subject: Method isn't hidden, but acts like it is at runtime To: ###@###.### Cc: ###@###.### import java.util.*; import static java.lang.System.out; public class T2 { public static void main(String[] args) { Collection c = T2a.m(new ArrayList<String>()); // => "T2a.m" } static Collection m(List<String> p) { out.println("T2.m"); return null; } } class T2a extends T2 { static Collection m(List<Number> p) { out.println("T2a.m"); return null; } }
|