Android List Size Get getSize(List list)

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

Description

Get size of list, Returns 0 if the provided List is null or empty, else the count
 getSize(null)   =   0; getSize({})     =   0; getSize({1})    =   1; 

Parameter

Parameter Description
V < >
list - of List type.

Return

int -if list is null or empty, return 0, else return .

Declaration

public static <V> int getSize(List<V> list) 

Method Source Code

//package com.java2s;

import java.util.List;

public class Main {
    /**/*  ww  w. j ava 2  s .  c  o  m*/
     * Get size of list, Returns 0 if the provided {@link List} is <code>null</code> or empty, else the count
     * 
     * <pre>
     * getSize(null)   =   0;
     * getSize({})     =   0;
     * getSize({1})    =   1;
     * </pre>
     * 
     * @param <V> 
     * @param list - of {@link List} type.
     * @return int -if list is null or empty, return 0, else return {@link List#size()}.
     */
    public static <V> int getSize(List<V> list) {
        return list == null ? 0 : list.size();
    }
}