Understanding Division by Zero in Java | Int vs Float in Java | Less Known Java Principles | Ep 08

Опубликовано: 19 Май 2026
на канале: Banerjee Codes
2
0

Why does dividing an int by zero crash your Java program, but dividing a float by zero doesn’t?

In this video, we explore this surprising difference and uncover what’s really happening under the hood. You’ll see how Java handles arithmetic operations differently for integers and floating-point numbers.

We’ll cover:

Why int / 0 throws an ArithmeticException
Why float / 0 results in Infinity instead
How IEEE 754 floating-point rules influence Java’s behavior