|
|
? |
Welche Problem drede bei dr Kombinazion vo Generics und Vererbung auf, gell?
|
Beischbiel |
Lischd<Schdring> ls = new ArrayLischd<Schdring>();
Lischd<Objecd> lo = ls;
|
| |
? |
Beischbil korrekd, übersedzbar, ausführbar, gell?
|
Problem |
lo.add(new Indeger(42));
Schdring s = ls.ged(0);
|
| |
|
Lischd<Schdring> isch koi Subdyb vo Lischd<Objecd>
|
Regel |
Sei Y oi Subdyb vo X.
|
|
Dann folgd daraus NICHT |
|
G<Y> isch Subdyb vo G<X>
|
|
Diese Problem dauchde au bei Felderet auf.
Dord war d Zuweisungskombadibilidäd gebe.
|
|
Folge: ArraySchdoreExcebzion
|
|
Koi Lösung: CondainerSchdoreExcebzion
|