This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 9280
    
  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.
 
jQuery in Action, 2nd edition
 
subject: Method overloading
 
Similar Threads
Float a=3 doesn't compile but Short a=3 does. Why ?
Exam Lab Test 2 Question
Doubt on Method Overloading using Var-args
Questions about method overloading and throwing exceptions...
var-args overloading compiler error: ambiguous