这个怎么理解啊求大神帮忙
names[i].length
names[i].length
2019-05-16
String[][] names={{"tom","jack","mike"},{"zhangsan","lisi","wangwu"}};
for (int i = 0; i < names.length ; i++) {
for (int j = 0; j < names[i].length; j++) {
System.out.println( names[i][j] );
}
System.out.println();
}
第一个循环会把names拆分成两个数组第一个为:{"tom","jack","mike"} 第二个为{"zhangsan","lisi","wangwu"}
第二层循环names[i].length当i为0的时候names[i].length的值表示{"tom","jack","mike"} 的数组长度
names[i].length当i为1的时候names[i].length的值表示{"zhangsan","lisi","wangwu"} 的数组长度
举报