Java Object Array Create toObjectArray(char... array)

Here you can find the source of toObjectArray(char... array)

Description

to Object Array

License

Open Source License

Declaration

public static Character[] toObjectArray(char... array) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static final Character[] EMPTY_CHARACTER_OBJECT_ARRAY = new Character[0];
    public static final Integer[] EMPTY_INTEGER_OBJECT_ARRAY = new Integer[0];
    public static final Long[] EMPTY_LONG_OBJECT_ARRAY = new Long[0];
    public static final Short[] EMPTY_SHORT_OBJECT_ARRAY = new Short[0];
    public static final Byte[] EMPTY_BYTE_OBJECT_ARRAY = new Byte[0];
    public static final Float[] EMPTY_FLOAT_OBJECT_ARRAY = new Float[0];
    public static final Double[] EMPTY_DOUBLE_OBJECT_ARRAY = new Double[0];
    public static final Boolean[] EMPTY_BOOLEAN_OBJECT_ARRAY = new Boolean[0];

    public static Character[] toObjectArray(char... array) {
        if (array == null)
            return null;
        if (array.length == 0)
            return EMPTY_CHARACTER_OBJECT_ARRAY;

        Character[] result = new Character[array.length];

        for (int i = 0; i < array.length; i++)
            result[i] = array[i];/*from ww  w  .j  a  v a  2 s .  com*/

        return result;
    }

    public static Integer[] toObjectArray(int... array) {
        if (array == null)
            return null;
        if (array.length == 0)
            return EMPTY_INTEGER_OBJECT_ARRAY;

        Integer[] result = new Integer[array.length];

        for (int i = 0; i < array.length; i++)
            result[i] = array[i];

        return result;
    }

    public static Long[] toObjectArray(long... array) {
        if (array == null)
            return null;
        if (array.length == 0)
            return EMPTY_LONG_OBJECT_ARRAY;

        Long[] result = new Long[array.length];

        for (int i = 0; i < array.length; i++)
            result[i] = array[i];

        return result;
    }

    public static Short[] toObjectArray(short... array) {
        if (array == null)
            return null;
        if (array.length == 0)
            return EMPTY_SHORT_OBJECT_ARRAY;

        Short[] result = new Short[array.length];

        for (int i = 0; i < array.length; i++)
            result[i] = array[i];

        return result;
    }

    public static Byte[] toObjectArray(byte... array) {
        if (array == null)
            return null;
        if (array.length == 0)
            return EMPTY_BYTE_OBJECT_ARRAY;

        Byte[] result = new Byte[array.length];

        for (int i = 0; i < array.length; i++)
            result[i] = array[i];

        return result;
    }

    public static Float[] toObjectArray(float... array) {
        if (array == null)
            return null;
        if (array.length == 0)
            return EMPTY_FLOAT_OBJECT_ARRAY;

        Float[] result = new Float[array.length];

        for (int i = 0; i < array.length; i++)
            result[i] = array[i];

        return result;
    }

    public static Double[] toObjectArray(double... array) {
        if (array == null)
            return null;
        if (array.length == 0)
            return EMPTY_DOUBLE_OBJECT_ARRAY;

        Double[] result = new Double[array.length];

        for (int i = 0; i < array.length; i++)
            result[i] = array[i];

        return result;
    }

    public static Boolean[] toObjectArray(boolean... array) {
        if (array == null)
            return null;
        if (array.length == 0)
            return EMPTY_BOOLEAN_OBJECT_ARRAY;

        Boolean[] result = new Boolean[array.length];

        for (int i = 0; i < array.length; i++)
            result[i] = array[i];

        return result;
    }
}

Related

  1. toObjectArray(boolean arr[])
  2. toObjectArray(boolean[] primitiveArray)
  3. toObjectArray(byte[] array)
  4. toObjectArray(int[] array)
  5. toObjectArray(int[] array)
  6. toObjectArray(int[] oldArray)
  7. toObjectArray(Object array)