Test if entities array is empty. - Java Collection Framework

Java examples for Collection Framework:Array Element Filter

Description

Test if entities array is empty.

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        Object[] entities = new String[] { "1", "abc", "level", null,
                "java2s.com", "asdf 123" };
        System.out.println(isEmpty(entities));
    }/*from w  w w  .  j a  va  2s  .  c o m*/

    /** Test if entities array is empty.
     *
     * @param entities to test if it is empty.
     * @return true if entities array is null or entities array length is zero.
     */
    public static boolean isEmpty(Object[] entities) {
        return entities == null
                || (entities != null && entities.length == 0);
    }
}

Related Tutorials