Java tutorial
//package com.java2s; import java.util.List; import java.util.Map; public class Main { /** * For logging, extremely unnecessary. * * @param list * @return */ public static <T> String list2str(List<T> list) { StringBuilder sb = new StringBuilder(); if (list != null && !list.isEmpty()) { sb.append("["); for (T t : list) { sb.append(t.toString()).append(", "); } sb.delete(sb.length() - 2, sb.length()); sb.append("]"); } return sb.toString(); } /** * Beware, the valid word "null" is also rendered as empty. * * @param str * @return */ public static boolean isEmpty(String str) { return str == null || "".contentEquals(str) || "null".contentEquals(str); } public static <K, V> boolean isEmpty(Map<K, V> map) { return map == null || map.isEmpty(); } public static <T> boolean isEmpty(List<T> l) { return l == null || l.isEmpty(); } }