/help
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)
14 Replies
⌛
This post has been reserved for your question.
Hey @Yarden! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
@Fischstaebchen
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
Seems like fixed, thank you so much ❤️
Is that possible to get explanation why it happens?
It's like a bug of for-each loop?
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
Thank you very muchhhhhh
I'll try to simplify it with Collection.sort as you suggested.
I never used it, so hopefully it's going to work
And thank you for the explanation, it made sense in my head
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Is there a way I can save this post so I don't lose it?
Before i'll close it
Unknown User•13mo ago
Message Not Public
Sign In & Join Server To View
Done
Thank you again ❤️
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Post Closed
This post has been closed by <@218019068219883520>.