-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
7
-
unknown
-
generic
1) ************************************
import java.util.List;
class A {
static String foo(List<Integer> l) {return null;}
}
class B extends A {
static Integer foo(List<Integer> l) {return null;}
}
/usr/local/home/maurizio/Desktop/Test3.java:8: foo(java.util.List<java.lang.Integer>) in B cannot override foo(java.util.List<java.lang.Integer>) in A; attempting to use incompatible return type
Integer foo(List<Integer> l) {return null;}
^
required: java.lang.String
found: java.lang.Integer
1 error
(2) ************************************
import java.util.List;
class A {
static String foo(List<Integer> l) {return null;}
}
class B extends A {
static Integer foo(List<String> l) {return null;}
}
Test3.java:8: name clash: foo(java.util.List<java.lang.String>) in B and foo(java.util.List<java.lang.Integer>) in A have the same erasure, yet neither overrides the other
static int foo(List<String> l) {return 0;}
^
1 error
import java.util.List;
class A {
static String foo(List<Integer> l) {return null;}
}
class B extends A {
static Integer foo(List<Integer> l) {return null;}
}
/usr/local/home/maurizio/Desktop/Test3.java:8: foo(java.util.List<java.lang.Integer>) in B cannot override foo(java.util.List<java.lang.Integer>) in A; attempting to use incompatible return type
Integer foo(List<Integer> l) {return null;}
^
required: java.lang.String
found: java.lang.Integer
1 error
(2) ************************************
import java.util.List;
class A {
static String foo(List<Integer> l) {return null;}
}
class B extends A {
static Integer foo(List<String> l) {return null;}
}
Test3.java:8: name clash: foo(java.util.List<java.lang.String>) in B and foo(java.util.List<java.lang.Integer>) in A have the same erasure, yet neither overrides the other
static int foo(List<String> l) {return 0;}
^
1 error
- relates to
-
JDK-6249774 hide vs override error message
- Open