0d: 00h: 00m: 00s

🎁 Get 3 extra months of learning — completely FREE

That's 90 extra days to master new skills, build more projects, and land your dream job.

Become a PRO
Background Image

🎁 Get 3 extra months of learning completely FREE

Become a PRO
Zeenat Bibi
last year
Zeenatcountry asked

In double, can we use both int and floating-point data types?

Kelish Rai
Expert
last year
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.