The double Keyword

The double is a Java keyword that may not be used as identifiers i.e. you cannot declare a variable or class with this name in your Java program

The double Keyword

The double Keyword

     

The double is a Java keyword that may not be used as identifiers i.e. you cannot declare a variable or class with this name in your Java program. It is used to declare a variable, an expression or a method return value of type double-precision floating-point number. It is also a java primitive data type that represents 64-bit floating-point value. It ranges from 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative). For decimal values, this data type is generally the default choice. The Java wrapper class associated with the double data type is called Double that is defined in java.lang package.

To declare a variable used to hold such a decimal number, you can use the double keyword.

The syntax of declaring a double type variable is shown as: 

double <variable-name> = <float-value>;

 For example:

double d = 667.60; 

The default value for the double data types is 0.0d.

Here is an example:

public class DoubleDemo { 

  public static void main(String[] args) { 

  double area = 6.15;

  System.out.print("Area: ");

  System.out.print(area);

  }

}