• 数组的用法


     int[] a = new int[3];
                a[0] = 5;
                int[] a1 = { 1, 2, 3 };
                int[] a2 = new int[] { 1, 2 };
                int[] a3 = new int[3] { 1, 2,3 };
                int[] a5;
                a5=new int[5];
    
    
                //多维数组,数组两个数不能为空
                int [,] b=new int[3,4];
                int[,] b4;
                b4 = new int[2, 3];
                //int[,] b5=new int[3,];//错误
                b[0, 0] = 1;
                int [,] b1=new int[,]{{1,2},{2,3},{1,3}};
                b1[0, 0] = 6;
                int[,] b2 = { { 1, 2 }, { 2, 3 }, { 1, 3 } };
                int[,] b3 = new int[2, 3] { { 2, 3, 1 }, { 1, 2, 3 } };
                //int[,] b4 = new int[2, 3] { { 2, 3, 1 } };//错误
    
    
                //交错数组第一个不能为空,第二个必须为空
                int[][] c = new int[2][];
                int[][] c2;
                c2 = new int[2][];
                //交错数组可以使用数组直接赋值
                c2[0] = a1;
                c2[1][0] = 2;
                int [][] c1=new int[1][]{new int[]{1}};
               // int[][] c3 = new int[1][] { { 1 } };//错误
                //int [][] c1=new int[1][1]{new int[]{1}};//错误
  • 相关阅读:
    struts2类型转换
    struts2拦截器
    计算机系统结构
    struts2标签
    struts2 OGNL表达式
    使用bootstrap
    Struts2-综合项目
    拦截器,课3
    struts2之OGNL
    Struts2框架
  • 原文地址:https://www.cnblogs.com/zhao123/p/3474582.html
Copyright © 2020-2023  润新知