Moving data from a HashSet to ArrayList in Java
You can use the Stream and collector to do this, I hope it is the easiest way
listname = setName.stream().collect(Collectors.toList());
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)
.
You simply need to loop:
Set<Set<String>> setTemp = new HashSet<Set<String>> ();
List<List<String>> list = new ArrayList<List<String>> ();
for (Set<String> subset : setTemp) {
list.add(new ArrayList<String> (subset));
}
Note: you should start variable names in small caps to follow Java conventions.
You can use addAll()
:
Set<String> gamesInstalledTemp = new HashSet< Set<String> >();
List<String> gamesInstalled = new ArrayList<>();
gamesInstalled.addAll(gamesInstalledTemp);