java generics - returning subtype announced form method


my category implementing super-class slight which advantage list<jcomponent>. list being returned read-only:



public summary category superclass {
open summary list<jcomponent> getcomponents();
}


in class, i wish relapse domain announced list - i.e. sub-list:



public category subclass extends superclass {
private list<jbutton> buttons;
open list<jcomponent> getcomponents() {
relapse buttons;
}
}


this generates compiler error, list<jbutton> subtype list<jcomponent>.



i know since doesn't compile, shouldn't certified supplement jtextfield list jbuttons.



however, list read-only, following "conceptually" should allowed. but, course, compiler doesn't know read-only.



is there any proceed grasp i wish achieve, but changing slight chapter super-class, domain chapter sub-class?



thanks,
calum



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members