/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)
No description
No description
No description
14 Replies
JavaBot
JavaBot13mo ago
This post has been reserved for your question.
Hey @Yarden! Please use /close or the Close 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.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
Yarden
YardenOP13mo ago
@Fischstaebchen
No description
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
Yarden
YardenOP13mo ago
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?
JavaBot
JavaBot13mo ago
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
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
Yarden
YardenOP13mo ago
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
JavaBot
JavaBot13mo ago
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.
Yarden
YardenOP13mo ago
Is there a way I can save this post so I don't lose it? Before i'll close it
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
Yarden
YardenOP13mo ago
Done Thank you again ❤️
JavaBot
JavaBot13mo ago
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.
JavaBot
JavaBot13mo ago
Post Closed
This post has been closed by <@218019068219883520>.
Want results from more Discord servers?
Add your server