Java length() 方法
length() 方法用于返回字符串的长度。
长度等于字符串中 16 位 Unicode 代码单元的数量。
语法
public int length()
参数
无
返回值
返回字符串长度。
实例
public class Test {
public static void main(String args[]) {
String Str1 = new String("www.facesoho.com");
String Str2 = new String("facesoho" );
System.out.print("String Str1 length :");
System.out.println(Str1.length());
System.out.print("String Str2 length :");
System.out.println(Str2.length());
}
}以上程序执行结果为:
String Str1 length :16 String Str2 length :8

尊贵的董事大人
英文标题不为空时 视为本栏投稿
需要关键字 描述 英文标题