Here you can find the source of getSize(List
getSize(null) = 0; getSize({}) = 0; getSize({1}) = 1;
Parameter | Description |
---|---|
V | a parameter |
sourceList | a parameter |
public static <V> int getSize(List<V> sourceList)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { /**// ww w . ja v a2 s .co m * get size of list * * <pre> * getSize(null) = 0; * getSize({}) = 0; * getSize({1}) = 1; * </pre> * * @param <V> * @param sourceList * @return if list is null or empty, return 0, else return {@link List#size()}. */ public static <V> int getSize(List<V> sourceList) { return sourceList == null ? 0 : sourceList.size(); } }