Java tutorial
//package com.java2s; import java.util.List; public class Main { /** * * @param list * @return true : trim some null obj */ public static boolean trimList(List list) { if (isEmpty(list)) { return false; } else { int length = list.size(); for (int i = length - 1; i >= 0; i--) { Object obj = list.get(i); if (obj == null) { list.remove(obj); } } return length != list.size(); } } public static boolean isEmpty(List list) { if (list == null || list.isEmpty()) { return true; } else { return false; } } }