zoukankan      html  css  js  c++  java
  • 20180521 数组

    For the following Java or C# code(3 Points),What will my Array3[2][2] returns?

    1
    2
    3
    4
    5
    6
    int [][] myArray3 = 
    new int[3][]{ 
    new int[3]{5,6,2}, 
    new int[5]{6,9,7,8,3}, 
    new int[2]{3,2}
    }; 
    9
    2
    6
    overflow

    答案:D
    本题考查的是基本的语法知识。无论是Java语言还是C#语言,在计算机的基本语法中,数组始终是以0开始,对于一个具有n个元素的一位数组,其下标是从0到n-1。因此本例中定义的二维数组myArray3[][],第一个元素对应的下标表示为myArray3[0][0],问题中的myArray3[2][2]理解为第三行第三个元素,查找原始数据发现,第三行仅包含两个元素,超出了数组可访问的位置,发生溢出。
    Java中会报出异常java.lang.ArrayIndexOutOfBoundsException。
     
  • 相关阅读:
    c copy
    IfcVertexLoop
    qt windeployqt 日志
    IfcPolyLoop
    IfcEdgeLoop
    IfcLoop
    QTableWidget
    QList删除元素
    matlab X的负次方函数绘制2
    matlab X的负次方函数绘制1
  • 原文地址:https://www.cnblogs.com/kxzh/p/9069215.html
Copyright © 2011-2022 走看看