list.add(1, object)
看一下add方法的註釋java
/** * Inserts the specified element at the specified position in this list * (optional operation). Shifts the element currently at that position * (if any) and any subsequent elements to the right (adds one to their * indices). * * @param index index at which the specified element is to be inserted * @param element element to be inserted * @throws UnsupportedOperationException if the <tt>add</tt> operation * is not supported by this list * @throws ClassCastException if the class of the specified element * prevents it from being added to this list * @throws NullPointerException if the specified element is null and * this list does not permit null elements * @throws IllegalArgumentException if some property of the specified * element prevents it from being added to this list * @throws IndexOutOfBoundsException if the index is out of range * (<tt>index < 0 || index > size()</tt>) */ void add(int index, E element);
翻譯(有不對的地方及時指正)this
/** * 在List中指定的位置上插入指定的元素 * (可選操做)。 將當前處於該位置的元素 * (若是有的話) 和任何後續的元素向右移 (增長他們的下標)。 * * @param index 指定被插入元素的下標 * @param element 要插入的元素 * @throws UnsupportedOperationException 若是此List不支持添加操做 * @throws ClassCastException 若是指定元素的類阻止它被添加到這個List中 * @throws NullPointerException 若是指定元素爲null而且該List不容許null元素 * @throws IllegalArgumentException 若是指定元素的某些屬性防止它被添加到這個List中 * @throws IndexOutOfBoundsException 若是下標超出範圍(下標 < 0 || 下標 > size()) */ void add(int index, E element);
總結:對API不熟翻譯