aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes var-args Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "var-args" Watch "var-args" New topic
Author

var-args

Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521


this prints 1 whereas



this prints some absurd value..why? isnt int boxed to integer here?


scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
because second time you are passing an object(primitive int array) not an array of objects(class Integer) so, I think its giving you the address of the int[] object but when you pass Integer[] object you have a new integer at every index and the class' tostring method returns the value hold in the object.


SCJP 1.6 96%
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
Thanks Neha...that was superb
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521


and why do i get a warning here? but not when i use static void m(Object[] o) ?




and here i thught the output to be c because according to a rule var-args are chosen if no option is left....but output is 1

is this becasue of being specific...that is Object... is more specific than Object afterall Object... is an Object[] and we are passing an Integer[] /???/ too much confusion....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: var-args