Java List to Int List toIntArray(List list)

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

Description

to Int Array

License

Open Source License

Declaration

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

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2014,2015 Hideki Yatomi
 * All rights reserved. This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/

import java.util.*;

public class Main {
    public static int[] toIntArray(List<Integer> list) {
        int[] array = new int[list.size()];
        for (int i = 0; i < list.size(); i++) {
            array[i] = list.get(i);/*from   ww w .j a v  a 2 s  .c o m*/
        }
        return array;
    }

    public static int[] toIntArray(BitSet bitSet) {
        int[] array = new int[bitSet.cardinality()];
        int i = 0;
        for (int b = bitSet.nextSetBit(0); b >= 0; b = bitSet.nextSetBit(b + 1)) {
            array[i++] = b;
        }
        return array;
    }
}

Related

  1. toIntArray(List integerList)
  2. toIntArray(List intList)
  3. toIntArray(List list)
  4. toIntArray(List list)
  5. toIntArray(List list)
  6. toIntArray(List list)
  7. toIntArray(List list)
  8. toIntArray(List list)
  9. toIntArray(List list)