Problem with chaining *confusing results*
I'll post entire code: "public class Ball { private double x,y,xStep,yStep; public Ball(double x, double y, double xStep, double yStep) { this.x = x; this.y = y; this.xStep = xStep; this.yStep = yStep; } public double getX() { return this.x; } public double getY() { return this.y; } public double getXStep() { return this.xStep; } public double getYStep() { return this.yStep; } public void setX(double x) { this.x = x; } public void setY(double y) { this.y = y; } public void setXStep(double xStep) { this.xStep = xStep; } public void setYStep(double yStep) { this.yStep = yStep; } @Override public String toString() { return "Ball{" + "x=" + x + ", y=" + y + ", xStep=" + xStep + ", yStep=" + yStep + '}'; } public double []getXY(){ double[]results=new double[2]; results[0]=this.x; results[1]=this.y; return results; } public void setXY(double x,double y){ this.x=x; this.y=y; } public double[]getXYStep(){ double []results=new double[2]; results[0]=this.xStep; results[1]=this.yStep; return results; } public void setXYStep(double xStep,double yStep){ this.xStep=xStep; this.yStep=yStep; } public Ball move(){ x+=xStep; y+=yStep; return this; } } " public class TestBall { public static void main(String[] args) { Ball b1=new Ball(1,2,11,12); System.out.println(b1); b1.setXY(5,6); b1.setXYStep(15,16); System.out.println(b1); System.out.println("x is: " + b1.getXY()[0]); System.out.println("y is: " + b1.getXY()[1]); System.out.println("xStep is: " + b1.getXYStep()[0]); System.out.println("yStep is: " + b1.getXYStep()[1]); System.out.println(b1.move()); System.out.println(b1.move().move().move()); System.out.println(b1.move().move()); } }" *results for .move* Ball{x=20.0, y=22.0, xStep=15.0, yStep=16.0} Ball{x=65.0, y=70.0, xStep=15.0, yStep=16.0} Ball{x=95.0, y=102.0, xStep=15.0, yStep