How to convert int to double in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to convert int to double in java?

how

8th Mar 2017, 9:01 PM
‫ברוך רוטקוף‬‎
‫ברוך רוטקוף‬‎ - avatar
3 Answers
+ 9
Herrmann is right. Upcasting is no problem, be careful at downcasting. For more information just search for these tags on Google.
8th Mar 2017, 9:31 PM
Tashi N
Tashi N - avatar
+ 3
You can't convert an integer to a double. Just think about it. You can go the other way around, but not from int to double.
8th Mar 2017, 9:15 PM
J.G.
J.G. - avatar
+ 2
You dont need to convert them explicitly because double is bigger than int. This is xalled implicit type conversion. If you want you could also write double d =Double.valueOf (YOUR INT); but you can write double d =YOUR INT too;
8th Mar 2017, 9:16 PM
Hermann Set
Hermann Set - avatar