1.ArrayList
ArrayList是一种泛类型的容器,换句话说ArrayList可以存放任意的Object
但是如果这个Object是自己写的话,在取出它时需要强制类型转换。
1.1ArryList长啥样
ArrayLsit<Element> a=new ArrayList<Element>();
2. ArrayList Methods总结
Return | Method | Description |
---|---|---|
boolean | add(E e) | Appends the specified element to the end of this list. |
void | add(int index,E element) | Inserts the specified element at the specified position in this list. |
boolean | addAll(int index,Collection<? extends E> c) | Inserts all of the elements in the specified collection into this list, starting at the specified position. |
void | clear() | Removes all of the elements from this list. |
Object | clone() | Returns a shallow copy of this ArrayList instance. |
E | get(int index) | Returns the element at the specified position in this list. |
boolean | isEmpty() | Returns true if this list contains no elements. |
E | remove(int index) | Removes the element at the specified position in this list. |
int | size() | Returns the number of elements in this list. |