Java examples for Collection Framework:Array Element Filter
Test if entities array is not empty.
//package com.java2s; public class Main { public static void main(String[] argv) { Object[] entities = new String[] { "1", "abc", "level", null, "java2s.com", "asdf 123" }; System.out.println(isNotEmpty(entities)); }// ww w.ja v a 2s . co m /** Test if entities array is not empty. * * @param entities to test if is not empty. * @return true if entities is not null and its length is more than zero. */ public static boolean isNotEmpty(Object[] entities) { return !isEmpty(entities); } /** Test if entities array is empty. * * @param entities to test if it is empty. * @return true if entities array is null or entities array length is zero. */ public static boolean isEmpty(Object[] entities) { return entities == null || (entities != null && entities.length == 0); } }