I've created a class that represents polynomial.
In order to create the polynomial I get 2 parameters in the constructor:
(1) Parameter of arrayList<Double> that represents the coefficients
(2) Parameter of ArrayList<Integer> that represents the powers.
for example:
The polynomial = 6x^3 + 5x^2 + 3x^1
Means:
Coefficients are: 6, 5, 3
Powers are: 3, 2, 1
If the 2 arrays are different in size it will throw an Exception (Already did it)
The problem:
I need to reorganize the arrays that they will be organized by increasing-order (relative to the powers' ArrayList), so I created a private method named "sortArray" that get the 2 parameters.
The problem is, when I delete a cell from one of the arrays (only one of them, which is obviously a mistake, but I'm trying to practice everything) it detects it and throw an exception.
The question is:
Why does it throw an exception if we already passed the throw part from the constructor?
We already inside a different code in a different place, why does it still detects the throw exception from the constructor?
Hopefully I was understandable!
Thank you!
P.S:
The part I marked in yellow is the mistake because I didn't delete the current's cell from the powers' ArrayList as well.