0

If we have these class :

abstract class Figure{
}

class Cercle extends Figure{    
}

And if I write :

Vector<Figure> v = new Vector<Cercle>();

I have error :

incompatible types: Vector<Cercle> cannot be converted to Vector<Figure>

If someone know how it doesn't work, I am interesting to know why. Thank you and sorry for my English.

Bidonjour
  • 329
  • 2
  • 11

1 Answers1

0

Answered many many times. Generic types in Java are not covariant.

Crazyjavahacking
  • 9,343
  • 2
  • 31
  • 40