FAQ

Java

JSP

Servlet


Advertisement



How to Convert a HashSet to an ArrayList?

This code example shows how to convert HashSet to ArrayList:

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class HashSetToArrayList {

public static void main(String[] args) {

Set<String> hashset = new HashSet<String>();
hashset.add("A");
hashset.add("B");
hashset.add("C");
List<String> list = new ArrayList<String>(hashset);
System.out.println(list.toString());

}
}


Printer-friendly version Printer-friendly version | Send this 
article to a friend Mail this to a friend

Previous Next vertical dots separating previous/next from contents/index/pdf Contents

  |   |