Using java double data type with example

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


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.

 

Was this article helpful?

Related Articles

Leave A Comment?