共計 204 個字符,預計需要花費 1 分鐘才能閱讀完成。
要獲取字符串的長度,可以使用 String 類的 length() 方法。
例如:
String str = "Hello World";
int length = str.length();
System.out.println("字符串的長度為:" + length); // 輸出:字符串的長度為:11
在上面的例子中,使用 length() 方法獲取了字符串 str 的長度,并將其打印出來。
丸趣 TV 網 – 提供最優質的資源集合!
正文完