Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Point allow you to access x and y directly?

Tags:

java

awt

Both x and y and integers, while getX() and getY() returns a doubles.

Why aren't there e.g. getXIntValue(), getXDoubleValue() and vice versa for y?

like image 731
whirlwin Avatar asked Dec 27 '22 20:12

whirlwin


2 Answers

Note the @since in the Javadoc -- 1.0

There is broad consensus that Point was very poorly designed.

like image 130
Dilum Ranatunga Avatar answered Feb 04 '23 10:02

Dilum Ranatunga


Point extends Point2D and Point2D has getX() and getY() defined as returning double. As @Dilum mentions above, its bad design from the stone ages of java.

like image 34
Sai Avatar answered Feb 04 '23 09:02

Sai