Zeenat
asked

Expert
Kelish Rai answered
Yes, a double in Java can store both whole numbers (integers) and decimal numbers (floating-point values).
For example:
// Store an integer
double num1 = 10;
// Store a decimal number
double num2 = 10.5;Note that even though 10 is an integer, Java automatically converts it to 10.0 when stored in a double variable.
Java
This question was asked as part of the Learn Java Basics course.
Our Experts
Sudip BhandariHead of Growth/Marketing
Apekchhya ShresthaSenior Product Manager
Kelish RaiTechnical Content Writer
Abhilekh GautamSystem Engineer
Palistha SinghTechnical Content Writer
Sarthak BaralSenior Content Editor
Saujanya Poudel
Abhay Jajodia
Nisha SharmaTechnical Content Writer
Udayan ShakyaTechnical Content Writer