Moving data from a HashSet to ArrayList in Java

Ghadeer picture Ghadeer · Nov 29, 2012 · Viewed 34k times · Source

I have the following Set in Java:

Set< Set<String> > SetTemp = new HashSet< Set<String> >();

and I want to move its data to an ArrayList:

ArrayList< ArrayList< String > > List = new ArrayList< ArrayList< String > >);

Is it possible to do that ?

Answer

abhishek ringsia picture abhishek ringsia · Sep 23, 2014

Moving Data HashSet to ArrayList

Set<String> userAllSet = new HashSet<String>(usrAllTemp);
List<String> usrAll = new ArrayList<String>(userAllSet);

Here usrAllTemp is an ArrayList, which has some values. Same Way usrAll(ArrayList) getting values from userAllSet(HashSet).