Quick Reach
The double data type
Among the eight primitive data types in Java, the double is one of those. It is like the float data type but with a double precision. A few main points about the Java double data type are:
- A double type variable takes 64 bits or eight bytes memory.
- The double is a numeric type with double-precision.
- The Default value of the double variable is 0.0d.
A double data type example
Following is a simple example to show how to declare and use the double variables. For illustration purpose, we have used two variables, a and b. The variable a is declared and no value is assigned at the time of declaration. The double variable b is assigned a value at the time of declaration.
After that, the value of the variable b is printed on screen by using the System.out.println.
Experience this online
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
public class variable_example {
public static void main(String []args) {
double a;
double b=(double)123456.789;
a=(double)100.25;
System.out.println(b); // Java Variable example
}
}
|
The output of the above code will be:
123456.789
The java double data type is the numeric type like int, byte, short, long and float. However, it is with the double precision whereas the float, java data type is with the single precision.
Leave A Comment?