Here you can find the source of isEmpty(Collection
isEmpty(null) = true; isEmpty({}) = true; isEmpty({1}) = false;
Parameter | Description |
---|---|
V | < > |
c | a parameter |
public static <V> boolean isEmpty(Collection<V> c)
//package com.java2s; import java.util.Collection; public class Main { /**/* w w w. j ava2 s .c o m*/ * is null or its size is 0 * * <pre> * isEmpty(null) = true; * isEmpty({}) = true; * isEmpty({1}) = false; * </pre> * * @param <V> * @param c * @return if collection is null or its size is 0, return true, else return false. */ public static <V> boolean isEmpty(Collection<V> c) { return (c == null || c.size() == 0); } }