Java has two types for decimal numbers. float uses 32 bits and needs an f at the end of a value, for example 10.8f. double uses 64 bits and is more precise, so it is the usual choice for decimals.
The example below calculates the area of a circle using the formula pi x r x r and prints the result.
Float In Java
Example : DoubleDemo
class DoubleDemo {
public static void main(String args[]) {
double a;
float r = 10.8f,pi = 3.1416f;
a = pi*r*r;
System.out.println("Area of circle is"+a);
}
}

