Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.9k views
in Technique[技术] by (71.8m points)

AIDE (Android-based) Java IDE automatically downcast object

I wrote the following line of code in AIDE some times ago while learning Java, saw it again tonight and I was baffled

Integer aaa = Integer.sum(new Integer(9),new Object())

I ain't drunk actually (and should know that the sum method of the Integer class doesn't take an Object as a parameter) but what makes feel like I do is the fact that the IDE compiles the code and run it.

A ClassCast exception was thrown which gives the impression that the IDE probably downcast the object as such the code that get run under the scene is probably

Integer aaa = Integer.sum(new Integer(9),(Integer) new Object())

but who does that?? All my life I believe DownCasting was never meant to be automatic or I am probably missing something?

I could easily tell myself it's a bug in the IDE or something like that but that would make me a fool who guesses rather thank ask question. Please what am I missing here??


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...