double keyword in java
In Java, ” double ” is a primitive type.
A double variable stores a double−precision 64-bit floating point value.
Examples
double ratio = .01;
double diameter = 6.15;
double height = 1.35E03; // 1.35 * 103 or 1350.0
double height = 1e−2; // 1.0 * 10−2 or 0.01
The double keyword can be used as a method parameter as below:
- public void displayMarks(double marks) {
- System.out.println("Total percentage marks "+marks);
- }
public void displayMarks(double marks) {
System.out.println("Total percentage marks "+marks);
}
The double keyword can be used as a return type of a method as well:
- public double getMarks() {
- return 94.5;
- }
public double getMarks() {
return 94.5;
}