java中ArrayList有什么用

ArrayList的用法 
馬克-to-win:ArrayList是List接口的眾多實(shí)現(xiàn)類其中的一個(gè): 可以使我們快速訪問(wèn)元素,馬克-to-win:為什么?因?yàn)樗膬?nèi)部組成結(jié)構(gòu)就像Array一樣,而且提供了可以直接訪問(wèn)第幾個(gè)元素的方法比如下面例子中的get(index),但往其中插入和刪除元素時(shí),速度卻稍慢。與LinkedList相比,它的效率要低許多。(因?yàn)長(zhǎng)inkedList的內(nèi)部像個(gè)Link, 參考數(shù)據(jù)結(jié)構(gòu))ArrayList遍歷時(shí)要用到Iterator(見(jiàn)下)。(新手可忽略)和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是線程安全的,但多數(shù)情況下不使用Vector,因?yàn)榫€程安全需要更多的系統(tǒng)開(kāi)銷。
馬克- to-win:馬克 java社區(qū):防盜版實(shí)名手機(jī)尾號(hào): 73203。
一個(gè)ArrayList的實(shí)例:

例: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");
    }
}

輸出結(jié)果是:

b

[a, b, c, d]