Here you can find the source of newListWhenNull(List
Parameter | Description |
---|---|
list | a parameter |
public static <T> List<T> newListWhenNull(List<T> list)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { public static <T> List<T> newListWhenNull(List<T> list) { if (isEmpty(list)) { list = new ArrayList<T>(); }/*from w ww. jav a2s. c om*/ return list; } public static <T> boolean isEmpty(List<T> list) { return list == null || list.size() == 0; } }