long

Java's primitive type for whole numbers too large for int, stored in 64 bits.

In more detail

A long literal needs an L suffix, as in 9000000000L, or the compiler treats the number as an int and rejects it as too large. The course uses a long to store a price as a whole number of cents, which avoids the rounding errors of double.

Examples

long total = 9000000000L;
public record Price(long cents) { }

Related terms

Taught in

References

Certification courses