Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Java Pointクラスが2つのintパラメーターを受け取り、getX()メソッドとgetY()メソッドがdoubleを返す理由として私は混乱しています。たとえば、ポイントを定義できます
Point p = new Point(4,6);
電話するなら…
p.getX();
4.0を返します。そして私が電話するなら
p.x;
私は4を得るでしょう。
これには何か理由がありますか?
のスーパークラスである拡張クラスがPoint2D.Doubleあり、浮動小数点値を処理できる必要があります。もあることに注意してください。Point2D.FloatPoint2DPointsetLocation( double, double )
Point2D.Double
Point2D.Float
Point2D
Point
setLocation( double, double )
Point2Dは、ポイントの距離計算を実装する抽象クラスであり、、、setLocationおよびgetXはgetYその抽象メソッドです。そのため、これらはすべて使用doublesされ、署名にsを使用Pointして実装する必要があります。double
setLocation
getX
getY
doubles
double