java中ArrayList有什么用

ArrayList的用法 
马克-to-win:ArrayList是List接口的众多实现类其中的一个: 可以使我们快速访问元素,马克-to-win:为什么?因为它的内部组成结构就像Array一样,而且提供了可以直接访问第几个元素的方法比如下面例子中的get(index),但往其中插入和删除元素时,速度却稍慢。与LinkedList相比,它的效率要低许多。(因为LinkedList的内部像个Link, 参考数据结构)ArrayList遍历时要用到Iterator(见下)。(新手可忽略)和vector相比: (from java documentation: ArrayList is roughly equivalent to Vector, except that it is unsynchronized.()there is no synchronized keyword in the ArrayList source code.if multithread access ArrayList, you need to use synchroized keyword in your code yourself.).Vector是线程安全的,但多数情况下不使用Vector,因为线程安全需要更多的系统开销。
马克- to-win:马克 java社区:防盗版实名手机尾号: 73203。
一个ArrayList的实例:

例:1.1.1

import java.util.ArrayList;

public class TestMark_to_win {
    public static void main(String args[]) {
        ArrayList l = new ArrayList();
        l.add("a");l.add("b");l.add("c");l.add("d");
        System.out.println(l.get(1) + "\n");
        System.out.println(l + "\n");
    }
}

输出结果是:

b

[a, b, c, d]