In Java, double is a datatype. It is used for storing decimal numbers with high precision. It is a 64-bit IEEE 754 floating-point data type, meaning it can handle large values and fractions accurately. We often see it in scientific calculations, financial applications, and physics simulations.
Syntax:
Example:
In Java, we can declare and initialize double variables to store decimal values.
Output:
Value of pi: 3.141592653589793 Radius: 6.5
We can use double variables in arithmetic operations like addition, subtraction, multiplication, and division.
Output:
Sum: 14.7 Difference: 6.3 Product: 44.1 Quotient: 2.5
The force of gravity between two objects is determined using Newton's formula:
Where,
Output:
The gravitational force between Earth and the Moon is: 1.982 × 10²⁰ Newtons
The double keyword in Java is used for precise decimal calculations. It offers higher accuracy than float, making it ideal for scientific research, financial applications, and mathematical computations. With its wide range and precision, double ensures reliable numerical results, helping developers build accurate and efficient Java programs that handle complex arithmetic operations.
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India