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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -