Anand Shrivastava
SCJA
SCJP 6 83%
Working on SCWCD/OCPJWCD
Anand Shrivastava
SCJA
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
When it's obvious that you have to do it, just do it without shattering your thoughts over different directions.
SCJP 6
SCJP 5
SCJP5 85%
SCJP 6
Regards,<br />aparna
All code in my posts, unless a source is explicitly mentioned, is my own.
We will keep things moving!!
akash azal wrote:can anyone clear about line no 9 in anand's post
SCJP 6
We will keep things moving!!
akash azal wrote:how it is processed for linr no8
SCJP 6
All code in my posts, unless a source is explicitly mentioned, is my own.
While overloading, Widening + vararg and Boxing + vararg can only be used in a mutually exclusive manner i.e. not together
Jose Francisco Ruiz Massieu wrote:yes I know, thats why it says (run doX(int... i) by rules 1 and 2), but what it's important (I think) is that, in this case both Widening + varargs , Boxing + vararg can be together, in the same class. So
While overloading, Widening + vararg and Boxing + vararg can only be used in a mutually exclusive manner i.e. not together
doesn't apply at all, do it???, what do you think???
SCJP 6
Fiona
SCJP 6
Punit Singh wrote:a.getNum(4);
here 4 is int
so for getNum(int... n)
it is only varargs.
int ---> int...
for getNum(Integer... n)
it is boxing + varargs.
int--->Integer--->varargs
Here rule no 4 applies, but we need to make rule no 4 more clear to cover this behavior also.
The call doX(1) is ambiguous as well. This looks like Rule 4 needs to be expanded, and a new rule similar to 4 added.
4. While overloading, Widening (or the identity conversion) + vararg and Boxing + vararg can only be used in a mutually exclusive manner i.e. not together.
4' While overloading, vararg and unboxing + vararg can only be used in a mutually exclusive manner i.e. not together.
All code in my posts, unless a source is explicitly mentioned, is my own.
Aakash Goel wrote:what a amazing post!
just wanted to clarify one thing though:
The conversion choosing long... here is 'Un'boxing and then Widening. Right?
SCJP 6
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Java Certification Exam Mock Tests: SCJA SCJP 5 SCJP 6 SCJP 6 (Online Training) SCJP 6 (Instructor Led Training) SCWCD 5 SCBCD 5 SCEA 5
Great Work done!!Anand Shrivastava wrote:Dear Friends,
Here I found a lot of confusion with regard to autoboxing, varargs and widening. Therefore, with the help of all the ranchers and moderators I propose to compile the rules in this regard which we shall call the Golden Rules. My perception is as under, on which I invite you all for an exhaustive discussion and to incorporate any modifications, if required, so that it may help all the SCJP aspirants.
Rules :
1. Primitive Widening > Boxing > Varargs.
2. Widening and Boxing (WB) not allowed.
3. Boxing and Widening (BW) allowed.
4. While overloading, Widening + vararg and Boxing + vararg can only be used in a mutually exclusive manner i.e. not together.
5. Widening between wrapper classes not allowed
Now Let me illustrate each of them with instances :
Dear friends, I am also a learner. So if i have made a mistake somewhere, please let me know. Moderators kindly help in this regard to consolidate the rules. Thanks in anticipation
[ July 28, 2008: Message edited by: Anand Shrivastava ]
Rajeev Kumar
SCJP 6.0 Certified 96%
SCJP 6
A wop bop a lu bob a womp bam boom. Tutti frutti ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|