Check that an array only contains null elements. - Java Collection Framework

Java examples for Collection Framework:Array Contain

Description

Check that an array only contains null elements.

Demo Code


//package com.java2s;

public class Main {


    /**//from   w  w w .ja  v  a 2s  .c om
     * Check that an array only contains null elements.
     * @param values, can't be null
     * @return
     */
    public static boolean containsOnlyNull(Object... values) {
        for (Object o : values) {
            if (o != null) {
                return false;
            }
        }
        return true;
    }
}

Related Tutorials