2019独角兽企业重金招聘Python工程师标准>>> ![hot3.png](https://www.oschina.net/img/hot3.png)
list.add(1, object)
看一下add方法的注释
/**
* 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);
翻译(有不对的地方及时指正)
/**
* 在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不熟
转载于:https://my.oschina.net/u/2968713/blog/777462
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)