JAVA: ImmutableSet as List -
i returned immutableset function call (getfeatures()) , due structure of rest of code executed later on- easier change list. have tried cast produces runtime exception. have looked around function call convert list no avail. there way this? recent [failed] attempt shown below:
immutableset<featurewrapper> wrappersset = getfeatures(); list<featurewrapper> wrappers = (list<featurewrapper>) wrappersset;
i have found wrapperset.aslist() give me immutablelist rather prefer mutable list
you can't cast set<t>
list<t>
. entirely-different objects. use copy constructor creates new list out of collection:
list<featurewrapper> wrappers = new arraylist<>(wrappersset);
Comments
Post a Comment