Valizada's blog

Java how to transform HashSet to ArrayList

The below code snippet demonstrates how to transform a set collection to list. Simply pass a set in constructor of List:

var set = new HashSet<String>();
set.add("one");
set.add("two");

var list = new ArrayList<String>(set);