I'm trying to create a program which represents a polynomial.
The class named "Polynom".
In order to create the polynomial which is a Pair<Double, Integer>, the constructor get 2 parameters, parameter of ArrayList<Double> represents the coefficients and parameter of ArrayList<Integer> represents the powers of the polynomial.
For example:
Polynomial P is P = 10x^3 + 8x^2 + 5x^1
Coefficients are: 10, 8 , 5
Powers are: 3, 2, 1
If the 2 parameters are different in size, the constructor will throw an Exception.
The question is:
Why it doesn't work?
In the main it doesn't create the polynomial even though the the ArrayLists are identical in size.. and instead it goes into the catch block and "turns on" the exception.
I marked the problematic line in the main in yellow, please help me, thank you!!
P.S:
Forgot to say, I created a private method which organizes the 2 arrays in decreasing order relative to the powers' ArrayList (So in the polynomial the highest power will be first and the lowest power will be last when I presents the polynomial)