Double and Number are boxed primitives. They are used, so we can process primitives such as objects. If you can use primitives then do it. They are much less memory and make calculations much faster.
In this case, if you want to convert Number to Double , you will need to make two throws. One to make Integer in int , and the other to make int in Double .
y2 = (double) (int) molWt[x];
Another compiler will also add a compiler. Equalization Alignment:
y2 = (Double) (double) (int) molWt[x];
However, you should just use the whole primitives, because this casting will kill your performance.
source share