< prev index next >

src/java.base/share/classes/java/lang/ArrayIndexOutOfBoundsException.java

Print this page
rev 49800 : 8201593: Print array length in ArrayIndexOutOfBoundsException.


  47      * specified detail message.
  48      *
  49      * @param s the detail message.
  50      */
  51     public ArrayIndexOutOfBoundsException(String s) {
  52         super(s);
  53     }
  54 
  55     /**
  56      * Constructs a new {@code ArrayIndexOutOfBoundsException} class with an
  57      * argument indicating the illegal index.
  58      *
  59      * <p>The index is included in this exception's detail message.  The
  60      * exact presentation format of the detail message is unspecified.
  61      *
  62      * @param index the illegal index.
  63      */
  64     public ArrayIndexOutOfBoundsException(int index) {
  65         super("Array index out of range: " + index);
  66     }
















  67 }


  47      * specified detail message.
  48      *
  49      * @param s the detail message.
  50      */
  51     public ArrayIndexOutOfBoundsException(String s) {
  52         super(s);
  53     }
  54 
  55     /**
  56      * Constructs a new {@code ArrayIndexOutOfBoundsException} class with an
  57      * argument indicating the illegal index.
  58      *
  59      * <p>The index is included in this exception's detail message.  The
  60      * exact presentation format of the detail message is unspecified.
  61      *
  62      * @param index the illegal index.
  63      */
  64     public ArrayIndexOutOfBoundsException(int index) {
  65         super("Array index out of range: " + index);
  66     }
  67 
  68     /**
  69      * Constructs a new {@code ArrayIndexOutOfBoundsException} class with an
  70      * argument indicating the illegal index and another indicating the length
  71      * of the accessed array.
  72      *
  73      * <p>The index and the length are included in this exception's detail message.
  74      * The exact presentation format of the detail message is unspecified.
  75      * This is called from within the VM.
  76      *
  77      * @param index the illegal index.
  78      * @param length the length of the accessed array.
  79      */
  80     private ArrayIndexOutOfBoundsException(int index, int length) {
  81         super("trying to access index " + index + " of an array with length " + length);
  82     }
  83 }
< prev index next >