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
廣告