public static int[] toArray(List<Integer> list) {
        if (list == null) return null;
        int[] array = new int[list.size()];
        for (int i = 0; i < list.size(); i++) {
            array[i] = list.get(i);
        }
        return array;
    }
Convert a list of integers to an array of ints.

@param list          The input list.
@return              The output array.
metadata/src/main/java/org/apache/kafka/metadata/Replicas.java