hash吗,还是一个个比较,还是怎的。

解决方案 »

  1.   

    Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method. 从源代码来看是按照容器元素的index搜索到第一次匹配的对象吧
      

  2.   

    这是源码
     public boolean contains(Object o) {
    return indexOf(o, 0) >= 0;
        }public synchronized int indexOf(Object o, int index) {
    if (o == null) {
        for (int i = index ; i < elementCount ; i++)
    if (elementData[i]==null)
        return i;
    } else {
        for (int i = index ; i < elementCount ; i++)
    if (o.equals(elementData[i]))
        return i;
    }
    return -1;
        }
      

  3.   

    呵呵,就是遍历一次,进行比较。 equals
      

  4.   

    哦,那速度可真是够慢的啊,我还以为用hash呢,谢谢各位!