Dave's Brain

Browse - Programming Tips - How can I convert a HashSet into an ArrayList ?

Date: 2012nov8
Language: Java

Q.  How can I convert a HashSet into an ArrayList ?

A.  There is a constructor of ArrayList that does that.
For example:

HashSet<String> myset = new HashSet<String>(); myset.add("one"); myset.add("two"); ArrayList<String> mylist = new ArrayList<String>(myset); // CONVERT

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.