本帖最后由 HM汪磊 于 2013-4-16 14:13 编辑
package cn.itcast.day1;
public class ReflectPoint {
int x,y;
public ReflectPoint(int x, int y) {
// TODO Auto-generated constructor stub
this.x=x;
this.y=y;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + x;//怎么这里有两个result语句,各有什么作用??最后返回哪个呢????
result = prime * result + y;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ReflectPoint other = (ReflectPoint) obj;
if (x != other.x)
return false;
if (y != other.y)
return false;
return true;
}
@Override
public String toString(){
return str1+"::::::"+str2+"::::::"+str3;
}
}
|