get Collection Size - Android java.util

Android examples for java.util:Collection Size

Description

get Collection Size

Demo Code


//package com.java2s;
import java.util.Collection;

import java.util.Map;

public class Main {
    public static int getSize(final Collection<?> collection) {
        if (collection == null) {
            return 0;
        }/*from   w  w w.  j a  v  a  2s  .co m*/
        return collection.size();
    }

    public static int getSize(final Map<?, ?> map) {
        if (map == null) {
            return 0;
        }
        return map.size();
    }
}

Related Tutorials