【JAVA】19、多维数组

来源:互联网 发布:电视连接网络 编辑:程序博客网 时间:2024/06/08 09:08

本篇博文最后修改时间:2016年2月29日,18:48。


一、简介

本篇介绍多维数组。


二、实验平台
系统版本:Windows7 家庭普通版 32位操作系统。

三、版权声明
博主:思跡
声明:喝水不忘挖井人,转载请注明出处。
原文地址:http://blog.csdn.net/omoiato

联系方式:315878825@qq.com

Java零基础入门交流群:541462902


四、多维数组

一维数组:int score []

二维数组:int score[][]

三维数组:int score[][][]

依此类推……

多维数组中,每多一维,循环就需多嵌套一层。

ps:一般不建议使用多维的数组进行操作。


范例:使用三维数组

public class ArrayDemo10{public static void main(String [] args){//定义一个三维数组,使用静态初始化方式int score[][][] = { { { 5, 1 }, { 6, 7 } },{ { 9, 4 }, { 8, 3 } } };for (int one = 0; one < score.length; one++)                           //第一层循环{for (int two = 0; two < score[one].length; two++)         //第二层循环{for (int three = 0; three < score[one][two].length; three++)//第三层循环{System.out.println("score["+one+"]["+two+"]["+three+"]="+score[one][two][three] +"\t");}}}}}


程序运行结果:



0 0