It's just an exercise but I can't figure out the ambiguity:
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);
}
It says:
The method flipFlop(String, int, Integer) is ambiguous for the type
Test
I would have guessed that the second argument would have been unwrapped to int and so the second flipFlop
method would have been the choice.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…