数组只有length方法没有length() ,字符串才有length().都是求长度的
例如:
int[] array = new int[]{1,3,-1,5,-2};int i = array.length;String c = "array";c.length();
public class string {
public static void main(String args[]){
int a[]={1,3,2,5,2,5};
String s=""+a[0];
for(int i=1;i<a.length;i++)
{
s+=","+a[i] ;
}
String b[]={"ss","sss","ss"};
System.out.println(s);
System.out.println(s.length());
System.out.println(b.length);
}
}
|