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

Method overloading

Rajshekhar Paul
Ranch Hand

Joined: Oct 17, 2006
Posts: 140
K&B SCJP 5.0 book -> Chapter 3: Assignments -> Overloading(section).

At the end of this "Overloading" section, there are few points of which two of them mentioned below seem to be confusing to me.

- Used individually, boxing and var-args are compatible with overloading.
- You can combine var-args with either widening or boxing.

Do not these two statements contradict each other? As according to me the first one means that boxing and var-args can not be combined in method overloading which directly opposes the last one.

Help needed.


When it's obvious that you have to do it, just do it without shattering your thoughts over different directions.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Originally posted by Rajshekhar Paul:
- Used individually, boxing and var-args are compatible with overloading.

first one means that boxing and var-args can not be combined in method overloading.


I think you have understood it wrong. I don't think the statement means in any way that you cannot combine var-args and boxing. It just says that you can overload a method with one of them having var-args and one having boxing. The book also tells that when there is a conflict between var-arg and boxing, boxing is chosen by the compiler...
[ December 05, 2008: Message edited by: Ankit Garg ]

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Rajshekhar Paul
Ranch Hand

Joined: Oct 17, 2006
Posts: 140
Thanks Ankit for clearing my doubt.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Method overloading