I'm writing program which operates on coordinate system so I need to use coordinates pretty often. I decided to use Point
class because it obviously allows to easily store coordinates of a point.
The problem is everywhere in my program I store it as int
whereas Point
returns double when using getX()
and getY()
methods. Of course I can easily cast it to int
but it doesn't look very elegant and adds unnecessary mess to the code.
Is it ok if I will just get the value directly? Like this:
Point p = new Point(0, 0);
int x = p.x;
instead of:
int x = p.getX();
I'm not even sure if it makes any difference, I just know that getters and setters are there for a reason and should be used.