Java tutorial
//package com.java2s; //License from project: Open Source License import android.support.annotation.Nullable; import android.text.TextUtils; import java.util.Collection; import java.util.Map; public class Main { @Nullable public static Class getComponentClass(Collection<?> list) { return isEmpty(list) ? null : list.iterator().next().getClass(); } public static <T> boolean isEmpty(T[] array) { return array == null || array.length == 0; } public static boolean isEmpty(int[] array) { return array == null || array.length == 0; } public static boolean isEmpty(long[] array) { return array == null || array.length == 0; } public static boolean isEmpty(Collection collection) { return collection == null || collection.isEmpty(); } public static boolean isEmpty(Map map) { return map == null || map.isEmpty(); } public static boolean isEmpty(String string) { return TextUtils.isEmpty(string); } public static boolean isEmpty(CharSequence cs) { return cs == null || cs.length() == 0; } }