Forums Register Login

Method overloading

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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 ]
+Pie Number of slices to send: Send
Thanks Ankit for clearing my doubt.
I guess everyone has an angle. Fine, what do you want? Just know that you cannot have this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 615 times.
Similar Threads
Doubt on Method Overloading using Var-args
Questions about method overloading and throwing exceptions...
var-args overloading compiler error: ambiguous
Exam Lab Test 2 Question
Float a=3 doesn't compile but Short a=3 does. Why ?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:22:41.