Java Set to Array setToArray(Set set)

Here you can find the source of setToArray(Set set)

Description

Sorted in ascending order.

License

Open Source License

Declaration

public static int[] setToArray(Set<Integer> set) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**Sorted in ascending order.*/
    public static int[] setToArray(Set<Integer> set) {
        List<Integer> l = new ArrayList<Integer>(set);
        Collections.sort(l);// w  w w.  j  a  v  a2s  .c o  m
        int[] intArray = new int[l.size()];
        for (int i = 0; i < intArray.length; ++i) {
            intArray[i] = l.get(i);
        }

        return intArray;
    }
}

Related

  1. setToArray(Set set)