is Collection Empty - Java java.util

Java examples for java.util:Collection Attribute

Description

is Collection Empty

Demo Code


//package com.java2s;

import java.util.Collection;

import java.util.Map;

public class Main {
    public static void main(String[] argv) {
        Collection c = java.util.Arrays.asList("asdf", "java2s.com");
        System.out.println(isEmpty(c));
    }//from  w  w w. j  a  va 2 s.c o m

    public static <V> boolean isEmpty(Collection<V> c) {
        return (c == null || c.size() == 0);
    }

    public static <K, V> boolean isEmpty(Map<K, V> sourceMap) {
        return (sourceMap == null || sourceMap.size() == 0);
    }
}

Related Tutorials