欧几里德平面中的点

Sanco Sanco 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
下面的程序定义了Point类,我的问题标在代码中
public class Point{
protected double x,y;

public Point(double x,double y)
{ this.x=x;
this.y=y;
}
public double getX()
{return x;
}
public double getY()
{return y;
}
public Point getLocal()
{ return new Point(x,y);
}
public void setLocal(double x,double y)
{ this.x= x;
this.y= y;
}
public void translate(double dx,double dy)
{ x+= dx;
y+= dy;
}

public boolean equals(Object ob)
{ if(ob==this) return true;
if(ob.getClass()!=this.getClass()) return false;
Point point=(Point)ob;
return(x==point.x&&y==point.y);
}//问题1

public int hashCode()
{ return(new Double(x).hashCode()+(new Double(x)).hashCode());
}//问题2

public String toString()
{ return new String("("+(float)x+" ,"+(float)y+")");
}
}
以上都编译通过,并且能用主类调用。
问题1:getClass是什么方法?有什么用。哪些类型能用它?
问题2:hashCode是什么方法?有什么用。哪些类型能用它?
不知我说的可详细,请赐教》》》》
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
Sanco
Java 51,407 成员 86,133 内容