Java List to Array toArray(List list)

Here you can find the source of toArray(List list)

Description

to Array

License

Apache License

Declaration

public static int[] toArray(List<Integer> list) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.List;

import java.util.Set;

public class Main {
    public static int[] toArray(List<Integer> list) {
        int[] result = new int[list.size()];
        int index = 0;
        for (Integer number : list) {
            result[index++] = number;/*  ww  w .j  a v  a 2s . c  o  m*/
        }
        return result;
    }

    public static int[] toArray(Set<Integer> set) {
        int[] result = new int[set.size()];
        int index = 0;
        for (Integer number : set) {
            result[index++] = number;
        }
        return result;
    }
}

Related

  1. toArray(List list)
  2. toArray(List values)
  3. toArray(List enums)
  4. toArray(List from, int[] to)
  5. toArray(List l)
  6. toArray(List list)
  7. toArray(List list)
  8. toLongList(String str, String splitStr)
  9. toLongList(String[] array)