关于length

length 属性(字符串)

返回字符串的长度。

str.length

参数

str
必选。一个字符串或 String 对象的名称。

备注

length 属性包含一个整数,该整数指示 String 对象中的字符数。String 对象中的最后一个字符的索引为 length - 1。

例如:
String[] ss={”1”,”22”,”333”,”4444”}
ss.length     //is 4
ss[0].length()    //is 1
前者是取得数组元素的个数
等价于array.length(xx)
后者是某相元素的长度
等价于string.length()
ss[2].length()    //is 3

posted @ 2008-04-14 16:06  牵牛望岳  阅读(315)  评论(0编辑  收藏  举报