Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Collection;

public class Main {
    public static final <T> boolean isNullOrEmpty(Collection<T> collection) {

        if (collection == null || collection.isEmpty()) {
            return true;
        }

        for (T item : collection) {
            if (item != null) {
                return false;
            }
        }

        return true;
    }

    public static final <T> boolean isNullOrEmpty(T[] array) {

        if (array == null || array.length <= 0) {
            return true;
        }

        for (T item : array) {
            if (item != null) {
                return false;
            }
        }

        return true;
    }
}