Java Primitive Type Create toPrimitiveArray(Byte[] array)

Here you can find the source of toPrimitiveArray(Byte[] array)

Description

to Primitive Array

License

Apache License

Declaration

public static byte[] toPrimitiveArray(Byte[] array) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static byte[] toPrimitiveArray(Byte[] array) {
        if (array == null) {
            return null;
        } else {//w w w  . jav a2 s  . c  o m
            byte[] result = new byte[array.length];
            for (int i = 0; i < array.length; i++) {
                result[i] = array[i];
            }
            return result;
        }
    }

    public static short[] toPrimitiveArray(Short[] array) {
        if (array == null) {
            return null;
        } else {
            short[] result = new short[array.length];
            for (int i = 0; i < array.length; i++) {
                result[i] = array[i];
            }
            return result;
        }
    }

    public static int[] toPrimitiveArray(Integer[] array) {
        if (array == null) {
            return null;
        } else {
            int[] result = new int[array.length];
            for (int i = 0; i < array.length; i++) {
                result[i] = array[i];
            }
            return result;
        }
    }

    public static long[] toPrimitiveArray(Long[] array) {
        if (array == null) {
            return null;
        } else {
            long[] result = new long[array.length];
            for (int i = 0; i < array.length; i++) {
                result[i] = array[i];
            }
            return result;
        }
    }

    public static float[] toPrimitiveArray(Float[] array) {
        if (array == null) {
            return null;
        } else {
            float[] result = new float[array.length];
            for (int i = 0; i < array.length; i++) {
                result[i] = array[i];
            }
            return result;
        }
    }

    public static double[] toPrimitiveArray(Double[] array) {
        if (array == null) {
            return null;
        } else {
            double[] result = new double[array.length];
            for (int i = 0; i < array.length; i++) {
                result[i] = array[i];
            }
            return result;
        }
    }

    public static char[] toPrimitiveArray(Character[] array) {
        if (array == null) {
            return null;
        } else {
            char[] result = new char[array.length];
            for (int i = 0; i < array.length; i++) {
                result[i] = array[i];
            }
            return result;
        }
    }

    public static boolean[] toPrimitiveArray(Boolean[] array) {
        if (array == null) {
            return null;
        } else {
            boolean[] result = new boolean[array.length];
            for (int i = 0; i < array.length; i++) {
                result[i] = array[i];
            }
            return result;
        }
    }
}

Related

  1. toPrimitive(Long[] array)
  2. toPrimitive(Long[] array)
  3. toPrimitive(Object o)
  4. toPrimitive(Object value)
  5. toPrimitiveArray(Boolean[] a)
  6. toPrimitiveArray(Byte[] bytes)
  7. toPrimitiveArray(Integer[] array)
  8. toPrimitiveArray(Object[] array)
  9. toPrimitiveArrayType(Class c)