[Solved] Calling an array in constructor in Java [closed]


You seem to have the assignments reversed,

public ChangePlane(String name, int[] array1){ 
  this.name = name; 
  this.array1 = array1;
  x1 = array1[0];
  y1 = array1[1];
  x2 = array1[2];
  y2 = array1[3];
  x3 = array1[4];
  y3 = array1[5];
  x4 = array1[6];
  y4 = array1[7];
}

Assuming you are passing an int[] array1 = new int[8]; (since array1[7] will fail otherwise) to your constructor anyway.

1

solved Calling an array in constructor in Java [closed]