Here you can find the source of isEmpty(String str)
String str=null; String str1=""; String str2="abc"; System.out.println(isEmpty(str));//true System.out.println(isEmpty(str1));//true System.out.println(isEmpty(str2));//false
Parameter | Description |
---|---|
string | a parameter |
public static boolean isEmpty(String str)
//package com.java2s; import java.util.List; public class Main { /**/* w w w . j a v a 2 s .c om*/ * Name: The string is null or empty * Description: When the string is null or empty return true,otherwise false * <blockquote><pre> * String str=null; * String str1=""; * String str2="abc"; * System.out.println(isEmpty(str));//true * System.out.println(isEmpty(str1));//true * System.out.println(isEmpty(str2));//false * </pre></blockquote> * @author Sky.liu * @date Nov 1, 2014 12:16:41 AM * @param string * @return true,false */ public static boolean isEmpty(String str) { return str == null || str.isEmpty(); } public static boolean isEmpty(List<?> list) { if (list == null || list.isEmpty()) { return true; } return false; } }