src/share/classes/java/util/ArrayList.java

Print this page

        

@@ -607,16 +607,18 @@
      * (If {@code toIndex==fromIndex}, this operation has no effect.)
      *
      * @throws IndexOutOfBoundsException if {@code fromIndex} or
      *         {@code toIndex} is out of range
      *         ({@code fromIndex < 0 ||
-     *          fromIndex >= size() ||
      *          toIndex > size() ||
      *          toIndex < fromIndex})
      */
     protected void removeRange(int fromIndex, int toIndex) {
         modCount++;
+        if (fromIndex > toIndex)
+            throw new IndexOutOfBoundsException(
+                    "From Index: " + fromIndex + " > To Index: " + toIndex);
         int numMoved = size - toIndex;
         System.arraycopy(elementData, toIndex, elementData, fromIndex,
                          numMoved);
 
         // clear to let GC do its work