3.3.2. Floating-Point Literals

Floating-point data types come in two flavors:

The default data type of a floating-point literal is double, but it can be explicitly designated by appending the suffix D (or d) to the value. A floating-point literal can also be specified to be a float by appending the suffix F (or f).

See the below table for examples of float and double literals in Java.

			package javatutorial;

			 * Example usage of Floating point literals in Java
			 * @author f5java.com
			public class FloatingPointLiterals {

				public static void main(String[] args) {
				float interestRate = 10.65f;
				float interestRate1 = 10.65F;
				double intRateDouble = 10.65;
				double intRateDouble1 = 10.659234802d;
				double intRateDouble2 = 10.65208349832D;
				System.out.println("Float values " + interestRate);
				System.out.println("Float values " + interestRate1);
				System.out.println("double values " + intRateDouble);
				System.out.println("double values " + intRateDouble1);
				System.out.println("double values " + intRateDouble2);