equals的问题
//public boolean equals(Object obj)
//{
//if (this == obj)
//return true;
//if (obj == null)
//return false;
//if (getClass() != obj.getClass())
//return false;
//Point other = (Point) obj;
//if (x != other.x)
//return false;
//if (y != other.y)
//return false;
//return true;
//}
//public boolean equals(Object obj)
//{
//Point p = (Point)obj;
//return this.x == p.x && this.y == p.y;
//}
public boolean equals(Object o)
{
if(o == null)
{
return false;
}
if(o == this)
{
//同一个对象
return true;
}
if(o instanceof Point)
{
Point other = (Point)o;
return this.x == other.x && this.y == other.y;
}
return false;
}
帮我分析下这几个方法的效率,尽量详细点 。系统提供的那个方法是不是效率最高为什么效率最高?????????、
[解决办法]
jdk 提供的当然是效率最高的!