• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Explanation ....

 
Vasiq Molvizadah
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm reading this Kathy Sierra Book and in one program...the output is kinda confusing...



The output of the program is
-434

I'm not getting this....any help
 
Rob Spoor
Sheriff
Pie
Posts: 20671
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A[] matches both A[]... and Object. Varargs is only used if no other method matches. That is why sifter(aa) uses Object and not A[]... It's also why B[] is used and not B[]...
Finally, 7 matches nothing directly. It is therefore boxed to Integer which then matches Object.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50289
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which Kathy Sierra book? You should always quote your sources. And "Explanation ...." doesn't tell us much of what the thread is about.
 
Vasiq Molvizadah
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Which Kathy Sierra book? You should always quote your sources. And "Explanation ...." doesn't tell us much of what the thread is about.


The name of the book is SCJP for Java 6 Study Guide - by Kathy Sierra and Bert Bates and I apologize for not giving a proper thread name.....
 
Vasiq Molvizadah
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:A[] matches both A[]... and Object. Varargs is only used if no other method matches. That is why sifter(aa) uses Object and not A[]... It's also why B[] is used and not B[]...
Finally, 7 matches nothing directly. It is therefore boxed to Integer which then matches Object.


Thanks for the explanation Rob.....
 
Campbell Ritchie
Sheriff
Pie
Posts: 50289
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the information, and apology accepted.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic