Java Integers

Introduction

Java has four integer types:

  • byte
  • short
  • int
  • long

All of these are signed, so they have both positive and negative values.

Java does not support unsigned, positive-only integers.

The width and ranges of these integer types vary widely, as shown in this table:

Name Width Range
long 64-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
int 32-2,147,483,648 to 2,147,483,647
short16-32,768 to 32,767
byte 8 -128 to 127



PreviousNext

Related