This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Method overloading

 
Rajshekhar Paul
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Rajshekhar Paul
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ankit for clearing my doubt.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic