is Iterable Empty - Java Collection Framework

Java examples for Collection Framework:Iterable

Description

is Iterable Empty

Demo Code


//package com.java2s;

public class Main {
    /**//from  w w w.j a  va2s. c  om
     * @param i
     *          An {@link Iterable} to check.
     * @return <code>true</code> if the parameter is <code>null</code> or it has
     *         an empty item set.
     */
    public static boolean isEmpty(Iterable<?> i) {
        return i == null || !i.iterator().hasNext();
    }
}

Related Tutorials