| Author |
why primitive variable can accept object ?
|
Alvin chew
Ranch Hand
Joined: Jan 08, 2004
Posts: 834
|
|
hi, good day , i wondering why following code is valid ? showform is an integer which create with "new Integer(2)", so it is "2" my understanding is request.getAttribute() will return object , it pretty well we can have cast with "Integer" , because "Integer" is class ...so it should be allowed but my question is after the casting ..the object will become "Integer" Object, but then why we can simply just put it into primitive type "int" ? thank you for answering
|
 |
Martin Mathis
Ranch Hand
Joined: Dec 20, 2004
Posts: 45
|
|
What version of the JDK are you using? I know one of the new 1.5 features is auto boxing/unboxing which should make what you're code is doing allowable. [ December 24, 2004: Message edited by: Martin Mathis ]
|
 |
Alvin chew
Ranch Hand
Joined: Jan 08, 2004
Posts: 834
|
|
oopss...i recently change to 1.5 ....so let say for 1.4 is not allow right ? thanks, Martin Mathis for answering
|
 |
 |
|
|
subject: why primitive variable can accept object ?
|
|
|