Convert the given set into integer array - Java Quiz Question


Write a program to convert the given input into integer array by using one of the Set interface methods.

Input (Set) Output (int[])
[15, 25, 99, 40, 10, 20, 30] {15, 25, 99, 40, 10, 20, 30}
[21, 2, 31, 25, 30, 0, 32, 22, 12, 36] {21, 2, 31, 25, 30, 0, 32, 22, 12, 36}
[7, 2, 8, 3, 1, 4, 5, 6, 10] {7, 2, 8, 3, 1, 4, 5, 6, 10}
null null


import java.util.*;
class CovertIntoArray
{
    public static void main(String s[])
    {
        Set input = new LinkedHashSet();
        input.add(1);
        input.add(3);
        input.add(2);
        input.add(5);
        input.add(4);
        for (Integer integer : convertToArray(input)) {
        System.out.println(integer);
        }

    }


    public static int[] convertToArray(Set input) {
    }

}