数组3

来源:互联网 发布:安讯士网络摄像机价格 编辑:程序博客网 时间:2024/06/07 04:54
/** * 数组 - 多维数组 * -- 二维数组 *  * @author admin */public class MultiArray {public void init() {/** * 多维数组  - 数组的数组 */int[] nums = {10, 20 , 30};int[][] numss = {{10, 20}, {22, 33, 44}};numss = new int[][]{{10, 20}, {22, 33, 44}};//int[][][] numsss = {{{122, 333}}};/* * 二位数组 行与列结构 * 0    1    2 * 010   20 * 122   33   44 */int[][] ns = new int[3][];ns = new int[3][2];//ns = new int[][2];   //wrongns[0][0] = 10;ns[0][1] = 20;//ns[0][2] = 30;ns[2][1] = 80;for(int[] nn : ns) {for(int n : nn) {System.out.print(n + "\t");}System.out.println();}System.out.println("-----------------------------------");for(int x = 0; x < ns.length; x++){for(int y = 0; y < ns[x].length; y++) {System.out.print(ns[x][y] + "\t");}System.out.println();}}public static void main(String[] args) {new MultiArray().init();}}

0 0
原创粉丝点击