比如
ArrayList a = new ArrayList();
ArryaList b = new ArrayList();
.. //
.. //中间已经都各自赋值了
.. //
a.get(5) = b.get(4);//为什么这个赋值就不行呢,小弟不懂
ArrayList a = new ArrayList();
ArryaList b = new ArrayList();
.. //
.. //中间已经都各自赋值了
.. //
a.get(5) = b.get(4);//为什么这个赋值就不行呢,小弟不懂
public E get(int index)返回此列表中指定位置上的元素。 指定者:
接口 List<E> 中的 get
指定者:
类 AbstractList<E> 中的 get
参数:
index - 要返回元素的索引
返回:
此列表中指定位置上的元素
抛出:
IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= size())--------------------------------------------------------------------------------set
public E set(int index,
E element)用指定的元素替代此列表中指定位置上的元素。 指定者:
接口 List<E> 中的 set
覆盖:
类 AbstractList<E> 中的 set
参数:
index - 要替代的元素的索引
element - 存储在指定位置上的元素
返回:
以前位于该指定位置上的元素
抛出:
IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index >= size())
get只是读数,要想赋值要用set吧