ArrayList的contains方法 java 今天在用ArrayList类的caontains方法是遇到了问题,我写了一个存放User类的ArrayList 但在调用list.contains(user)时总是返回false. 去看了下ArrayList的源码,源码如下: Java代码 public boolean contains(Object o) { return indexOf(o) >= 0; } public int indexOf(Object o) { if (o == n…
public class Student { private String name; private int age; private int id; public Student() { super(); } public Student(String name, int age, int id) { super(); this.name = name; this.age = age; this.id = id; } public String getName() { retur…