So, i'm a beginner in Java, and my teacher wants me to build a method that returns an Array of two elements. This is what i've made
public int[] getXY() {
int[] a = new int[2];
a[0]=getX();
a[1]=getY();
return a;
}
getX and getY returns this.x and this.y respectively. So obviously this method returns the reference to the array, not the elements of the array itself, which is what i want to do, but i've no ideas. He made it clear that the method has to return an Array of two elements, so that's why i didn't make it with String. Any suggestions?