Java - 删除重复项的ArrayList

zig*_*ggy 0 java collections scjp ocpjp

在以下示例中:

public static void main(String[] args){

        List<String> list = new ArrayList<String>();

        list.add("hi");
        list.add("hi");
        list.add("hi");

        list.remove("hi");

        System.out.println(list); //prints [hi, hi]

}
Run Code Online (Sandbox Code Playgroud)

ArrayList减少了一个但删除了哪一个?它是删除最后插入的还是最早插入的?

Pet*_*hev 7

来自文档 -Removes the first occurrence of the specified element from this list, if it is present.