The float type stores decimal numbers using bits, half the size of double. You must add an f suffix to float literals:
float temperature = 98.6f;
float rate = 0.05f;
Without the f, Java treats decimal numbers as double by default. Writing float x = 3.14; causes a compile error because you're trying to squeeze a -bit double into a -bit float.
When should you pick float over double? Almost never. double gives you about digits of precision, while float gives only . The memory savings rarely matter on modern hardware. You'll see float in game engines and graphics APIs where performance with millions of values matters. For everything else, stick with double.