List

目录

    void add(int index, E element);

    /**
     * Removes the element at the specified position in this list (optional
     * operation).  Shifts any subsequent elements to the left (subtracts one
     * from their indices).  Returns the element that was removed from the
     * list.
     *
     * @param index the index of the element to be removed
     * @return the element previously at the specified position
     * @throws UnsupportedOperationException if the <tt>remove</tt> operation
     *         is not supported by this list
     * @throws IndexOutOfBoundsException if the index is out of range
     *         (<tt>index &lt; 0 || index &gt;= size()</tt>)
     */
    

    List中有个add方法是指定index的,并不是将要插入的元素替换掉之前的元素,而是将之前的元素统统往left移动。谨记!

    posted @ 2020-09-07 10:35  西伯利亚爱学习的狼  阅读(123)  评论(0编辑  收藏  举报