• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Abhineet Kapil
Ranch Hand
Posts: 52
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because, Short is not an Integer. try this
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic