File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Explanation .... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Explanation ...." Watch "Explanation ...." New topic
Author

Explanation ....

Vasiq Molvizadah
Ranch Hand

Joined: Dec 24, 2009
Posts: 66
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


Human Knowledge Belongs to the World.
- Vasiq Mz
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36508
    
  16
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

Joined: Dec 24, 2009
Posts: 66
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

Joined: Dec 24, 2009
Posts: 66
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

Joined: Oct 13, 2005
Posts: 36508
    
  16
Thank you for the information, and apology accepted.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Explanation ....
 
Similar Threads
kathy sierra self test question..???
Study Guide 6 -- Chapter2 Self Test Question 15 on page 181.
Which overloaded method is called?
SCJP 1.6 Chapter2 Question 15- Answer -> is D ,I think it should be E
Static oveloaded methods with different argument list