Java Integer Create toIntegerArray(final int[] array)

Here you can find the source of toIntegerArray(final int[] array)

Description

Converts the primitive int array into an Integer wrapper object array.

License

Open Source License

Parameter

Parameter Description
array the primitive int array to convert into an Integer wrapper object array.

Return

an Integer array containing the values from the elements in the primitive int array.

Declaration

public static Integer[] toIntegerArray(final int[] array) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from   w ww .  j  av  a 2 s  .c om
     * Converts the primitive int array into an Integer wrapper object array.
     * </p>
     * @param array the primitive int array to convert into an Integer wrapper object array.
     * @return an Integer array containing the values from the elements in the primitive int array.
     */
    public static Integer[] toIntegerArray(final int[] array) {
        final Integer[] integerArray = new Integer[array == null ? 0 : array.length];

        if (array != null) {
            for (int index = 0; index < array.length; index++) {
                integerArray[index] = array[index];
            }
        }

        return integerArray;
    }
}

Related

  1. toInteger(String[] s)
  2. toInteger(String[] source)
  3. toInteger(StringBuilder value)
  4. toIntegerArray(byte[] input, int offset, int len)
  5. toIntegerArray(double[] doubles)
  6. toIntegerArray(final int[] ints)
  7. toIntegerArray(String text, String delimiter)
  8. toIntegerArray(String... values)
  9. toIntegerByObject(Object obj)