Java Collection Convert toPrimitiveIntegerArray(Collection collection)

Here you can find the source of toPrimitiveIntegerArray(Collection collection)

Description

to Primitive Integer Array

License

Open Source License

Declaration

public static int[] toPrimitiveIntegerArray(Collection<Integer> collection) 

Method Source Code

//package com.java2s;
/*// w  w w .j  a v a 2 s .c o m
 * Copyright (c) 2012, 2013 Mateusz Parzonka
 * 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
 *
 * Contributors:
 * Mateusz Parzonka - initial API and implementation
 */

import java.util.Collection;

public class Main {
    public static int[] toPrimitiveIntegerArray(Collection<Integer> collection) {
        int[] result = new int[collection.size()];
        int i = 0;
        for (Integer n : collection) {
            result[i++] = n;
        }
        return result;
    }
}

Related

  1. toMatrix(Collection collection)
  2. toObjectArray(Collection list)
  3. toObjectCollection(Object v)
  4. tooDelimitedString(final Collection coll, final String delim, final String prefix, final String suffix)
  5. toPrimitiveArray(final Collection values)
  6. toReadableString(Collection collection)
  7. toSeparatedString(Collection items, String separator)
  8. toSeperatedString(final Collection list)
  9. toSet(Collection c)

  10. HOME | Copyright © www.java2s.com 2016