Course contentsShow
← Java
Lesson 26 of 2,8702. Variables and Primitive TypesFree lesson

The int Type: Java's Default Integer

Learn int as the most common integer type, its 32-bit size, and range from -2,147,483,648 to 2,147,483,647.

The int Type: Java's Default Integer

What you'll learn: You'll discover Java's most commonly used data type for whole numbers and understand its size and range.

What is int?

In Java, int (short for "integer") is the default type for storing whole numbers—no decimals, no fractions, just counting numbers like -5, 0, 42, or 1000. Think of it like a storage box that can hold one number at a time, but it has limits on how big or small that number can be.

Size and Range

The int type uses 32 bits (or 4 bytes) of memory. Because of this fixed size, it can only represent numbers within a specific range:

  • Minimum value: -2,147,483,648 (about -2.1 billion)
  • Maximum value: 2,147,483,647 (about +2.1 billion)

Why These Numbers?

With 32 bits, Java can represent 2³² different values (roughly 4.3 billion possibilities). Half of these are negative, half are positive, and there's zero in the middle. It's like having a number line with about 4.3 billion tick marks total, centered at zero.

Why int is Default

When you write a whole number in Java code (like 42), Java automatically treats it as an int unless you tell it otherwise. It's the sweet spot—large enough for most everyday counting tasks, yet efficient enough not to waste memory.

Key Takeaway: int is Java's go-to type for whole numbers, storing 32-bit values from approximately -2.1 billion to +2.1 billion. When you need to count, track quantities, or work with whole numbers in your programs, int is your first choice.