| Author |
array
|
Raju Champaklal
Ranch Hand
Joined: Dec 10, 2009
Posts: 521
|
|
|
why cant i assign an int array to an Integer array?
|
scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
|
 |
Phungsuk Wangdu
Ranch Hand
Joined: Nov 04, 2009
Posts: 114
|
|
beacause the int cant be automatically boxed to Integer
whereas an Integer can be autoboxed to int automatically
well i may be wrong also just giving a try
|
 |
Neha Daga
Ranch Hand
Joined: Oct 30, 2009
Posts: 504
|
|
write a code and you will find the answer. If you are unable to understand after that, then I will tell you.
hint: arrays are object
|
SCJP 1.6 96%
|
 |
Raju Champaklal
Ranch Hand
Joined: Dec 10, 2009
Posts: 521
|
|
|
|
 |
Phungsuk Wangdu
Ranch Hand
Joined: Nov 04, 2009
Posts: 114
|
|
|
OOK i guess i am unable to understand please give us the reason
|
 |
Raju Champaklal
Ranch Hand
Joined: Dec 10, 2009
Posts: 521
|
|
|
we are waiting Neha
|
 |
W. Joe Smith
Ranch Hand
Joined: Feb 10, 2009
Posts: 710
|
|
Raju Champaklal wrote:we are waiting Neha
Here is a bit more of a hint: Arrays are objects. Integer is an object. Can you cast an Array to an Integer?
|
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
|
 |
Raju Champaklal
Ranch Hand
Joined: Dec 10, 2009
Posts: 521
|
|
|
nope because they arent in the same hierarchy..but so what? and what about float[] f=a? even this doesnt compile..why
|
 |
Phungsuk Wangdu
Ranch Hand
Joined: Nov 04, 2009
Posts: 114
|
|
|
well i got it now
|
 |
Raju Champaklal
Ranch Hand
Joined: Dec 10, 2009
Posts: 521
|
|
|
explain it to me Mahesh
|
 |
Raju Champaklal
Ranch Hand
Joined: Dec 10, 2009
Posts: 521
|
|
|
is it because int[] and Integer[] arent in the same hierrachy?
|
 |
Phungsuk Wangdu
Ranch Hand
Joined: Nov 04, 2009
Posts: 114
|
|
well just open your k&b and start reading page no 233 you will understand it
Its really easy
|
 |
Neha Daga
Ranch Hand
Joined: Oct 30, 2009
Posts: 504
|
|
|
you cant cast an array object that contains an int to an array object that contains float. think it is written in K&B you can add a short to an array of ints but can assign an array of short to an array of ints. I leave the reason for you to find it then I know you will understand it.
|
 |
Raju Champaklal
Ranch Hand
Joined: Dec 10, 2009
Posts: 521
|
|
time nahi he samjhne ka
|
 |
Neha Daga
Ranch Hand
Joined: Oct 30, 2009
Posts: 504
|
|
ok then just remember that array of one primitive type cant be assigned to array of another primitive type
and you can put short byte char and int in an array of int.
and about the wrapper array i think you got that
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9191
|
|
Raju Champaklal wrote:time nahi he samjhne ka 
If I remember, I told you before to not use Hindi on javaranch. People from all around the world visit javaranch, so please restrict yourself to using English...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Raju Champaklal
Ranch Hand
Joined: Dec 10, 2009
Posts: 521
|
|
|
sorry again....wont happen again
|
 |
 |
|
|
subject: array
|
|
|