Java List Size getSize(List list)

Here you can find the source of getSize(List list)

Description

get Size

License

Open Source License

Declaration

public final static int getSize(List<?> list) 

Method Source Code

//package com.java2s;

import java.util.Collection;
import java.util.List;
import java.util.Map;

public class Main {

    public final static int getSize(List<?> list) {
        if (isEmpty(list)) {
            return 0;
        }//from   ww  w . ja  v  a  2 s. c  o  m
        return list.size();
    }

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

    @SuppressWarnings("rawtypes")
    public static boolean isEmpty(Map map) {
        if (map == null || map.size() == 0) {
            return true;
        }
        return false;
    }

    @SuppressWarnings("rawtypes")
    public static boolean isEmpty(Collection collection) {
        if (collection == null || collection.size() == 0) {
            return true;
        }
        return false;
    }

    public static boolean isEmpty(Object[] objs) {
        if (objs == null || objs.length == 0) {
            return true;
        }
        return false;
    }
}

Related

  1. getSize(List list)
  2. getSize(List positions)
  3. getSize(List sourceList)
  4. getSize(List sourceList)