Search code examples
javapointtranslate

Java Translate Point


I know there is this method:

pt.translate(int x, int y);

But is there this method:

pt.translate(Point anotherPoint);

Would be the same as saying:

pt.translate(anotherPoint.x, anotherPoint.y);

But I thought there might be that method because it is simpler.


Solution

  • According to the docs, that is the only translate method. So, as you've said,

    pt.translate(anotherPoint.x, anotherPoint.y);
    

    is what you're looking for.

    Also, accessing the fields of an object is just about as simple as it gets :-)