The int Data Type - Java Language Basics

Java examples for Language Basics:int

Introduction

The int data type is a 32-bit signed Java primitive data type.

A variable of the int data type takes 32 bits of memory.

Its valid range is -2,147,483,648 to 2,147,483,647 (-2^31 to 2^31 - 1).

All whole numbers in this range are known as integer literals or integer constants.

For example, 10, -20, 0, 30, 9, etc. are integer literals of int.

An integer literal can be assigned to an int variable

  
int num = 2; 
  

Integer literals can also be expressed in

  • Decimal number format
  • Octal number format
  • Hexadecimal number format
  • Binary number format

Related Tutorials