Here is the piece of code.
public class MyPolynomial { private double coeffs[]; private int degree; public MyPolynomial(double ... coeffs) { if (coeffs != null && coeffs.length > 0) { this.coeffs = new double[coeffs.length]; System.arraycopy(coeffs, 0, this.coeffs, 0, coeffs.length); }
The class, constructors, and also all methods are marked as unused. But I used them in a test file. It compiles and works as expected.
Part of the test file:
MyPolynomial aTest = new MyPolynomial(1, 2, 3, 4, 5); System.out.println(aTest.getCoeffs()); System.out.println(aTest.getDegree()); System.out.println(aTest);
source share