Line 8. doStuff(x);
x can be boxed to an Integer or Object, but it can't be a Long, for Integer and Long are different subclasses of Number, casting fails.
and var-args is picked up last, 14. doStuff(Integer... i) has lower priority than 12. doStuff(Object o).
so Line 12 executes. s += "1";
why doStuff(Object o) not doStuff(Integer.... i)? I thought Boxing and Varags are allowed, then it should be doStuff(Integer.... i) right? And what do you mean by doStuff(Integer... i) has lower priority than doStuff(Object o)?
Weiheng Zhang, your explanation for each question is so clear and understandable. Congrats on your
SCJP score.