public boolean equals(Object obj) {
  if(this==obj) return true;
  if(obj==null) return false;
  if(this.getClass()!=obj.getClass()) return false;
  Date1 other=(Date1) obj;
  if(this.month!=other.month) return false;
  if(this.day!=other.day) return false;
  if(this.year!=other.year) return false;
  return true;
  
 }
这个重写中,通过 if(this.getClass()!=obj.getClass()) return false; 不就可以判断出obj是Date1的对象了吗?为什么还需要通过tDate1 other=(Date1) obj;将obj类型转换为Date1 对象?是不是这一行多余了?
qq_不睡觉的怪叔叔_0
					ziom
随时随地看视频慕课网APP
相关分类