Java String Empty isEmpty(String str)

Here you can find the source of isEmpty(String str)

Description

Name: The string is null or empty Description: When the string is null or empty return true,otherwise false
 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 

License

Open Source License

Parameter

Parameter Description
string a parameter

Return

true,false

Declaration

public static boolean isEmpty(String str) 

Method Source Code


//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;
    }
}

Related

  1. isEmpty(String input)
  2. isEmpty(String param)
  3. isEmpty(String sTest_)
  4. isEmpty(String str)
  5. isEmpty(String str)
  6. isEmpty(String text)
  7. isEmptyturnlane(String turns)
  8. isNotEmpty(String str)
  9. isNullOrEmpty(String message, String string)