Java List Size getSize(List sourceList)

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

Description

get size of list
 getSize(null)   =   0; getSize({})     =   0; getSize({1})    =   1; 

License

Apache License

Parameter

Parameter Description
V a parameter
sourceList a parameter

Return

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

Declaration

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

Method Source Code

//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();
    }
}

Related

  1. getSize(List list)
  2. getSize(List list)
  3. getSize(List positions)
  4. getSize(List sourceList)
  5. size(List list)
  6. size(Object[] list)
  7. sizeNotNull(final List list)
  8. sizeOf(List l)