Float Data Type in Java

 
The float data type represents a single-precision 32-bit IEEE 754 floating point.

Program to declare and use Java primitive float variable.

/**
 * Program to declare and use Java primitive float variable.
 * @author javawithease
 */
public class DataTypeFloatExample {	
  public static void main(String args[]){ 
	//Declare float type variables.
	float f1 = 32.454f;
	float f2 = 178.44f;
 
        //Print variables value.
        System.out.println("f1 Value: " + f1);
        System.out.println("f2 Value: " + f2);
 
        //Print Sum f1 and f2.
        System.out.print("Sum: ");
        System.out.println(f1 + f2);
  }
}

Output:

f1 Value: 32.454
f2 Value: 178.44
Sum: 210.894

Download this example.