if I change the declaration as:it produce output as:Code: Select all
int a = 10; Integer[] aa = { 10, 20 }; long l = 30; probe(a); probe(aa); probe(l);
In Integer
In Integer..
In Long
but my question is why probe(aa) print: In Integer..
while it can also print: In Object
asdeclaration becauseCode: Select all
int[]aa = {10, 20}
"aa" is also object.Code: Select all
Integer[]aa
About Question enthuware.ocpjp.v7.2.1736 :
Moderator: admin
-
- Posts: 12
- Joined: Thu Dec 11, 2014 12:32 am
- Contact:
About Question enthuware.ocpjp.v7.2.1736 :
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1736 :
Because the parameter that matches more precisely is the one that is selected. aa does match Object but it matches more closely to Integer[].
You will read about it in explanations of other questions where this concept is tested.
HTH,
Paul.
You will read about it in explanations of other questions where this concept is tested.
HTH,
Paul.
Who is online
Users browsing this forum: Bing [Bot] and 5 guests