java中如何获取数组长度和字符串长度的代码?

2024-12-29 17:31:01
推荐回答(1个)
回答1:

String s="gsdhgjsjsgdjh";
int a=s.length();//一定要有括号;
int a[]={45,5,8,45,21,6,68,4,8}
int b=a.length;//没有括号偶;b=9.
int a[]={{45,25},{89,6,7,1},{6,89,1},{9,6,2,1,2}};
int b=a.length//b=4,
int c=a[0].length// c=2
int d=a[3].length//d=5;;