This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes why this error is coming if Arrays are co-variant; Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "why this error is coming if Arrays are co-variant; "cannot convert from Short[] to Integer[]"" Watch "why this error is coming if Arrays are co-variant; "cannot convert from Short[] to Integer[]"" New topic
Author

why this error is coming if Arrays are co-variant; "cannot convert from Short[] to Integer[]"

Abhineet Kapil
Ranch Hand

Joined: Feb 08, 2010
Posts: 52

Arrays are co-variant and Collections are invariant.

I am try to assign an array of java.lang.Short to an array of java.lang.Integer.
But I am getting a compile time error.

Type mismatch: cannot convert from Short[] to Integer[]

Can someone please explain why this error is coming if Arrays are co-variant.


Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

because, Short is not an Integer. try this
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why this error is coming if Arrays are co-variant; "cannot convert from Short[] to Integer[]"
 
Similar Threads
Cast Object to Object[]
Java Generic Type on Class
Using for..each loop on Object[]
what is the real answer?
Wrappers