This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

var-args

 
Raju Champaklal
Ranch Hand
Posts: 521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


this prints 1 whereas



this prints some absurd value..why? isnt int boxed to integer here?
 
Neha Daga
Ranch Hand
Posts: 504
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raju Champaklal
Ranch Hand
Posts: 521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Neha...that was superb
 
Raju Champaklal
Ranch Hand
Posts: 521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic