Convert set to list - Java java.util

Java examples for java.util:List Convert

Description

Convert set to list

Demo Code


//package com.java2s;

import java.util.ArrayList;

import java.util.List;

import java.util.Set;

public class Main {
    public static <T> List<T> set_to_list(Set<T> set) {
        if (set == null)
            return null;
        List<T> list = new ArrayList<T>();
        for (T obj : set) {
            list.add(obj);//from w w w. j av a2  s.co m
        }
        return list;
    }
}

Related Tutorials