1./**
 * 使用ArrayList集合,向集合中插入Dog对象,三个,删除其中一个,判断是否包含对象(“小黑”,1).
 * @author Administrator
 *

 */Arraylist集合的简单运用

注意 这里的判断会用到equals 需要重写equal方法

 public boolean equals(Object anObject) {
if (this == anObject) {
return true;
}
if (anObject instanceof Dog) {
Dog d = (Dog) anObject;
if(this.name.equals(d.name)&& this.sex.equals(d.sex)){
return true;
}
}
return false;
}

相关文章:

  • 2022-02-20
  • 2021-07-04
  • 2021-11-23
  • 2022-12-23
  • 2022-01-29
猜你喜欢
  • 2021-11-20
  • 2021-08-20
  • 2021-11-16
  • 2021-09-04
  • 2021-08-26
  • 2021-07-06
相关资源
相似解决方案