Hi, Wondering why an int array int cannot be assigned to double so if int i and double d are two arrays then d = i is not allowed. Whereas if A a and B b are arrays of objects where class B is a subclass of class A then a = b is valid. Could anyone please throw some light on this ? Thanks Satya
Satya, Your observations are right. Primitive array assignments do not undergo automatic widening conversions. Though an int can be assigned to a long, an int array cannot be assigned to a long array, even with explicit cast.Java simply cannot convert from array of one primitive type to another. The only thing you can do, however, is assigning an int array to another int array. I know it is dumb, but they call it identity conversion. Rather a complicated term for a very trivial operation!! Ajith
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Satyashree , If you go thro RHE(page 118), it clearly states that: When oth Oldtype and Newtype are arrays, both arrays MUST CONTAIN reference type (NOT PRIMITIVES), and it must be legal to casrt an element of Oldtype to an element of Newtype.