解决方案 »

  1.   

    ArrayList调用remove时会按顺序和参数比较,把第一个相等的对象移除
    A类的equals方法始终返回true,就是说A类的对象和任何对象相等
    所以就把第一个对象移除了
      

  2.   

    public boolean remove(Object o) {
    if (o == null) {
                for (int index = 0; index < size; index++)
    if (elementData[index] == null) {
        fastRemove(index);
        return true;
    }
    } else {
        for (int index = 0; index < size; index++)
    if (o.equals(elementData[index])) {
        fastRemove(index);
        return true;
    }
            }
    return false;
        }从头往后遍历,你的A.equals始终返回true,当然就把第一个删掉了。