As you can see in the Oracle Documentation for java.awt.Point, x and y are stored as int
. However, getX
and getY
return double
. While there is a setLocation
method that takes 2 double
types, there is no constructor that does. Furthermore, the double
gets truncated to an int
internally anyway.
Is there a good reason for this? You might avoid a cast on setLocation
by having a method that takes double
types, but you have the opposite problem when you call getX
and getY
. There's also a misrepresentation of the precision of the Point class by returning a double
from getX
and getY
.