Here you can find the source of isNotEmpty(String str)
String str=null; String str1=""; String str2="abc"; System.out.println(isNotEmpty(str));//false System.out.println(isNotEmpty(str1));//false System.out.println(isNotEmpty(str2));//true
Parameter | Description |
---|---|
string | a parameter |
public static boolean isNotEmpty(String str)
//package com.java2s; import java.util.List; public class Main { /**//from w ww. ja va2s. c om * Name: The string is not null and empty * Description: When the string is not null and empty return true,otherwise false * <blockquote><pre> * String str=null; * String str1=""; * String str2="abc"; * System.out.println(isNotEmpty(str));//false * System.out.println(isNotEmpty(str1));//false * System.out.println(isNotEmpty(str2));//true * </pre></blockquote> * @author Sky.liu * @date Nov 1, 2014 12:16:41 AM * @param string * @return true,false */ public static boolean isNotEmpty(String str) { return !isEmpty(str); } /** * 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; } }