Java Primitive Type Create toPrimitive(Byte[] objectArray)

Here you can find the source of toPrimitive(Byte[] objectArray)

Description

to Primitive

License

Open Source License

Declaration

public static byte[] toPrimitive(Byte[] objectArray) 

Method Source Code

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

public class Main {
    public static byte[] toPrimitive(Byte[] objectArray) {
        byte[] primitiveArray = new byte[objectArray.length];
        for (int i = 0; i < objectArray.length; i++)
            primitiveArray[i] = objectArray[i];

        return primitiveArray;
    }/*ww  w  .j av a 2s  .  co m*/

    public static int[] toPrimitive(Integer[] objectArray) {
        int[] primitiveArray = new int[objectArray.length];
        for (int i = 0; i < objectArray.length; i++)
            primitiveArray[i] = objectArray[i];

        return primitiveArray;
    }

    public static double[] toPrimitive(Double[] objectArray) {
        double[] primitiveArray = new double[objectArray.length];
        for (int i = 0; i < objectArray.length; i++)
            primitiveArray[i] = objectArray[i];

        return primitiveArray;
    }

    public static long[] toPrimitive(Long[] objectArray) {
        long[] primitiveArray = new long[objectArray.length];
        for (int i = 0; i < objectArray.length; i++)
            primitiveArray[i] = objectArray[i];

        return primitiveArray;
    }

    public static float[] toPrimitive(Float[] objectArray) {
        float[] primitiveArray = new float[objectArray.length];
        for (int i = 0; i < objectArray.length; i++)
            primitiveArray[i] = objectArray[i];

        return primitiveArray;
    }
}

Related

  1. toPrimitive(Boolean b)
  2. toPrimitive(Boolean[] array)
  3. toPrimitive(Byte[] byteArray)
  4. toPrimitive(Byte[] bytes)
  5. toPrimitive(Character value)
  6. toPrimitive(Character[] in)
  7. toPrimitive(Class aClass)
  8. toPrimitive(Class clazz)