I'm studying to do my java OCA test, using the book "Java SE7 Programming Essentials" by Michael Ernest. This is my code for one of the answers to a question below:
public class Point3D {
    int x, y, z;
    public void setX(int x) {
        this.x = x;
    }
    public int getX() {
        return this.x;
    }
    public void setY(int y) {
        this.y = y;
    }
    public int getY() {
        return this.y;
    }
    public void setZ(int z) {
        this.z = z;
    }
    public int getZ() {
        return this.z;
    }
    public String toString(Point3D p) {
        String result = p.getX() + "," + p.getY() + "," + p.getZ();
        return result;
    }
    public static void main(String args[]) {
        Point3D point = new Point3D();
        point.setX(5);
        point.setY(12);
        point.setZ(13);
        System.out.println(point.toString(point));
    }
}
My code works, but in the last line, I think I've made my code in a weird way, shouldn't there be a way to make just point.toString() and not point.toString(point) return the String representation of the point? Can anyone explain to me how to fix it?
I'm sure it's a simple answer, just trying to understand it because I suspect it points to a hole in my java knowledge.
 
     
     
     
     
     
     
     
     
     
     
     
     
     
    