这只是一个练习,但我搞不懂模棱两可的地方:
private static void flipFlop(String str, int i, Integer iRef) {
System.out.println(str + "ciao");
}
private static void flipFlop(String str, int i, int j) {
System.out.println(str + "hello");
}
public static void main(String[] args) {
flipFlop("hello", new Integer(4), 2004);
}上面写着:
方法flipFlop(String,int,Integer)对于类型测试是不明确的。
我会猜到第二个参数将被打开到int中,因此第二个flipFlop方法将是选择。
发布于 2014-01-04 17:11:27
您的第二个参数2004 (即int )也适用于Integer,因为自动拳击,这就是编译器无法决定使用哪种方法的原因。
https://stackoverflow.com/questions/20923888
复制相似问题