Everything is theoretically impossible, until it is done. ~Robert A. Heinlein
Aditya Jha wrote:I would write it something like this:
Alex Armenteros wrote:Using tertiary operators
Double sum=(Double.valueOf(d1)==null?0.0:d1)+(Double.valueOf(d2)==null?0.0:d2)+(Double.valueOf(d3)==null?0.0:d3)+(Double.valueOf(d4)==null?0.0:d4);
This way dx can be a Double object or a double primitive or even a int,float,byte,etc and it will work as intended
Jeff Verdegan wrote:
Aditya Jha wrote:I would write it something like this:
Aditya, please remember that this site is NotACodeMill(⇐click) and that, as it says on the topics page, "We're all here to learn, so when responding to others, please focus on helping them discover their own solutions, instead of simply providing answers."
Aditya Jha wrote:
Jeff Verdegan wrote:
Aditya Jha wrote:I would write it something like this:
Aditya, please remember that this site is NotACodeMill(⇐click) and that, as it says on the topics page, "We're all here to learn, so when responding to others, please focus on helping them discover their own solutions, instead of simply providing answers."
Point taken, Jeff!
To be honest, I have always paid attention to this point, and have tried to put a hint to the solution in words as far as possible. However, for some reason, this question (and my solution) seemed like a case where writing the solution in words or code will not make much of a difference.
Evildoers! Eat my justice! And this tiny ad's justice too!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|