Java tutorial
//package com.java2s; import java.util.Collection; import java.util.Map; public class Main { public static String pickFirstNotNull(CharSequence... options) { if (isEmpty(options)) { return null; } String result = null; for (CharSequence cs : options) { if (null != cs) { result = cs.toString(); break; } } return result; } /** * ************************************************************* */ public static boolean isEmpty(Collection collection) { return null == collection || collection.isEmpty(); } public static boolean isEmpty(Map map) { return null == map || map.isEmpty(); } public static boolean isEmpty(Object[] objs) { return null == objs || objs.length <= 0; } public static boolean isEmpty(int[] objs) { return null == objs || objs.length <= 0; } public static boolean isEmpty(CharSequence charSequence) { return null == charSequence || charSequence.length() <= 0; } }