Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.util.List;

public class Main {
    public static final byte[] EMPTY_BYTE_ARRAY = new byte[0];

    public static byte[] toPrimitiveByte(final List<Byte> array) {
        if (array == null) {
            return null;
        }
        if (array.isEmpty()) {
            return EMPTY_BYTE_ARRAY;
        }
        final byte[] result = new byte[array.size()];
        for (int i = 0; i < array.size(); i++) {
            result[i] = array.get(i).byteValue();
        }
        return result;
    }

    public static boolean isEmpty(final boolean[] array) {
        return array == null || array.length == 0;
    }

    public static boolean isEmpty(final byte[] array) {
        return array == null || array.length == 0;
    }

    public static boolean isEmpty(final int[] array) {
        return array == null || array.length == 0;
    }

    public static boolean isEmpty(final long[] array) {
        return array == null || array.length == 0;
    }

    public static boolean isEmpty(final float[] array) {
        return array == null || array.length == 0;
    }

    public static boolean isEmpty(final double[] array) {
        return array == null || array.length == 0;
    }

    public static <T> boolean isEmpty(final T[] array) {
        return array == null || array.length == 0;
    }
}