/help
Initializing a Double and Integer values inside a private method returns Null in both.
But when I'm initializing them normally inside the constructor (without a private method) then everything works perfectly.
why?
(line 65)
Thank you!!
11 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•11mo ago
Message Not Public
Sign In & Join Server To View
Thank you, I will check it now
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.
@Twala
Here is the thing I don't understand.
Because it's pass-by-value, then the values that suppose to pass into polynomCoeff and PolynomPower are the values of polynom._coefficients.get(index) and polynom._powers.get(index) respectively, since it passes by them value of it...
But it passes Null instead of a value, that means both
polynom._coefficients.get(index)
and
polynom._powers.get(index)
are null, why? it makes non-sense
The pass-by value here are:
polynom._coefficients.get(index) and polynom._powers.get(index) right?
Unknown User•11mo ago
Message Not Public
Sign In & Join Server To View
I mean, constructors and methods aren't different. Here the variables have a conflicting scope because he declared parameters of the same name. It would be the same with a constructor.
That normally would have been responded with by that google search
Fundamentally, it just does't work to pass around parameters so that they're initialized. So trying to is useless. Instead, whatever you intend to do must be done another way
Here it would be easy to not pass the values you want as parameters, as passing null pointers is fundamentally useless, and instead just have the initiliazer method set the fields.
@Kyo-chan
Thank you very much!
I've managed to fix the problem
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 marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.