A program needs named places to hold numbers, text and flags, and Java makes you pick the type up front. The type decides the range: an int overflows past about 2.1 billion, so a sum of large values needs a long. Use double for measurements, but not for money or exact comparisons where rounding errors matter. Overflow from the wrong type is one of the most common reasons a correct-looking solution fails hidden tests.