Java Collection to Array toIntArray(final Collection c)

Here you can find the source of toIntArray(final Collection c)

Description

to Int Array

License

Open Source License

Parameter

Parameter Description
c a parameter

Declaration

public static int[] toIntArray(final Collection<? extends Number> c) 

Method Source Code


//package com.java2s;

import java.util.*;

public class Main {
    /**//from   w w  w  .j  ava  2  s.c om
     * @param c
     * @return
     */
    public static int[] toIntArray(final Collection<? extends Number> c) {
        if (c == null) {
            return null;
        }
        final int[] r = new int[c.size()];
        int i = 0;
        for (final Number n : c) {
            r[i++] = n.intValue();
        }
        return r;
    }

    public static int size(Collection<?> c) {
        return (c == null) ? 0 : c.size();
    }
}

Related

  1. toIntArray(Collection collection)
  2. toIntArray(Collection ints)
  3. toIntArray(Collection list)
  4. toIntArray(Collection list)
  5. toIntArray(Collection values)
  6. toIntArray(final Collection col)
  7. toIntArray(final Collection collection)
  8. toIntArray(final Collection values)
  9. toLongArray(Collection collection)