功能要求:定义一个两行三列的二维数组 names 并赋值,使用二重循环输出二维数组中的元素
names={{"tom","jack","mike"},{"zhangsan","lisi","wangwu"}};
运行结果效果:
代码:
public class lianxi13 {
public static void main(String[] args){
String[][] names={{"tom","jack","mike"},{"zhangsan","list","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();
}
}
}