I'm trying to send a one D array to a class. I want the mutator method to copy the array, save it and then send it back to my tester class...so far I keep getting errors from the compiler. I know how to write a method that copies the array in main but I can't seem to get it done with the class though. Here is the code:
public class Class1D {
private int degree;
private int [] coefficient;
    public Class1D(int degree){
    this.degree =degree;
    }
    public void setCoefficent( int[] a, int degree){
        this.coefficient[degree] = a[degree];
        for ( int i=0; i<=a.length-1; i++)
        {
            this.coefficient[i] = a[i];
        }
    }
      public int [] getCoefficient() {
          return coefficient;
    }
}
import javax.swing.JOptionPane;
public class copy1D{
    public static void main(String[]args)
    {
        String input;
        int degree;
        input = JOptionPane.showInputDialog(" what is the degree of the polynomial?");
        degree = Integer.parseInt(input);
        degree= degree+1;
        int [] array = new int[degree];
        for ( int i =0; i<=array.length-1; i++)
        {
            input = JOptionPane.showInputDialog(" Enter coefficients:");
            array[i] = Integer.parseInt(input);
        }
        for ( int i =0; i<=array.length-1; i++)
        {
            System.out.print(array[i] + " ");
        }
        Class1D array2 = new Class1D(degree);
    }
    }
}
 
    