Java Utililty Methods Primitive Type Create

List of utility methods to do Primitive Type Create

Description

The list of methods to do Primitive Type Create are organized into topic(s).

Method

booleantoPrimitive(Boolean b)
to Primitive
if (b == null) {
    return false;
return b.booleanValue();
boolean[]toPrimitive(Boolean[] array)
to Primitive
boolean[] primitiveArray = new boolean[array.length];
for (int i = 0; i < array.length; i++) {
    primitiveArray[i] = array[i];
return primitiveArray;
byte[]toPrimitive(Byte[] byteArray)
Converts an array of object Bytes to primitives handling null .
if (byteArray == null) {
    return null;
byte[] unbox = new byte[byteArray.length];
for (int i = 0; i < unbox.length; i++) {
    unbox[i] = byteArray[i];
return unbox;
...
byte[]toPrimitive(Byte[] bytes)
to Primitive
byte[] bytesAsPrimitives = new byte[bytes.length];
for (int i = 0; i < bytes.length; i++) {
    bytesAsPrimitives[i] = bytes[i];
return bytesAsPrimitives;
byte[]toPrimitive(Byte[] objectArray)
to Primitive
byte[] primitiveArray = new byte[objectArray.length];
for (int i = 0; i < objectArray.length; i++)
    primitiveArray[i] = objectArray[i];
return primitiveArray;
chartoPrimitive(Character value)
to Primitive
return null == value ? 0 : value.charValue();
char[]toPrimitive(Character[] in)
to Primitive
return toPrimitive(in, (char) 0);
ClasstoPrimitive(Class aClass)
Returns non primitive type for primitive.
for (int i = 0; i < _primitives.length; i++)
    if (aClass == _primMappings[i])
        return _primitives[i];
return aClass;
ClasstoPrimitive(Class clazz)
to Primitive
if (clazz == Boolean.class)
    return boolean.class;
if (clazz == Character.class)
    return char.class;
if (clazz == Byte.class)
    return byte.class;
if (clazz == Short.class)
    return short.class;
...
double[]toPrimitive(Double[] array)
to Primitive
if (array == null) {
    return null;
} else if (array.length == 0) {
    return new double[0];
final double[] result = new double[array.length];
for (int i = 0; i < array.length; i++) {
    result[i] = array[i].doubleValue();
...