Float:
float is 32 bit single precision type and used when fractional precision calculation is required.
Syntax:
Declare float varibale as below
float <variable name> = <default value>;
Note:
here assigning default value is optional.
import java.util.*;
public classFloat{
public static void main(String[] args) {
float f = 10.4f;
System.out.println("Value of float variable f is :" + f);
}
}
Output: |
---|
Value of float variable f is:10.4 |