如何访问arraylist对象的第n个元素?
来源:百度知道 编辑:UC知道 时间:2024/05/16 07:46:18
在c#中
ArrayList的类方法中就有一个:
get(int index)
Returns the element at the specified position in this list.
查查文档就看得到具体用法
java
java.util.ArrayList<E>
public E get(int index)返回此列表中指定位置上的元素。
http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/index.html
.net
http://msdn2.microsoft.com/zh-cn/library/system.collections.arraylist_members(VS.80).aspx
http://msdn2.microsoft.com/zh-cn/library/system.collections.arraylist.item(VS.80).aspx
使用索引器就行了.
比如
ArrayList list = new ArrayList();
list.Add(1);