Convert Set into List
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class Main {
public static void main(String[] args) {
Set<Object> set = new HashSet<Object>();
set.add("A");
set.add(new Long(10));
set.add(new Date());
List<Object> list = new ArrayList<Object>(set);
for (int i = 0; i < list.size(); i++) {
Object o = list.get(i);
System.out.println("Object = " + o);
}
}
}
Home
Java Book
Runnable examples
Java Book
Runnable examples
Collection Set:
- Convert set to an Array
- Convert Set into List
- Convert a set to a synchronized Set
- Is a particular value in(exist) Set
- Iterator a set
- Maximum element of Set
- Minimum element of a Set
- Remove all elements from a set
- Remove element from Set
- Remove one set from another set
- Remove all the elements from one set to another set
- Union(Add) all the elements from one set to another set
- Intersection of one set and another set
- Set operations: union, intersection, difference
- Set operations: symmetric difference, is subset, is superset
- Size of a Set