Java String isEmpty() 方法示例。


String 類的 isEmpty() 方法如果當前字串的長度為 0,則返回 true。

示例

 演示

import java.lang.*;
public class StringDemo {
   public static void main(String[] args) {
      String str = "tutorialspoint";
      //prints length of string
      System.out.println("length of string = " + str.length());
     
      //checks if the string is empty or not
      System.out.println("is this string empty? = " + str.isEmpty());
   }
}

輸出

length of string = 14
is this string empty? = false

更新於:2019 年 7 月 30 日

141 次瀏覽

開啟你的事業

透過完成課程獲取證書

開始學習
廣告