And*_*der 1 java overloading ambiguity
为什么不编译?我想知道根本原因.
如果
List<String>
Run Code Online (Sandbox Code Playgroud)
与...不是同一类型
List<Integer>
Run Code Online (Sandbox Code Playgroud)
为什么
public String convert(List<String> strings) { return null; }
Run Code Online (Sandbox Code Playgroud)
和
public String convert(List<Integer> strings) { return null; }
Run Code Online (Sandbox Code Playgroud)
做一个模棱两可的宣言?
public class Converter {
public void why() {
List<String> strings = null;
List<Integer> integers = null;
strings = integers; // type mismatch
}
public String convert(List<String> strings) {
// error: why is this ambiguous ?
return null;
}
public String convert(List<Integer> strings) {
// error: why is this ambiguous ?
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
477 次 |
| 最近记录: |