检查数组是否只包含不为空的元素。
/* 来 自* 时 代 J a v a */ //package com.nowjava; public class Main { /** * Check that an array only contains elements that are not null. * @param values, can't be null * @return */ public static boolean containsOnlyNotNull(Object... values) { for (Object o : values) { if (o == null) { return false; } } return true; } }