Java Primitive Data Types

In this chapter you will learn:

  1. What are the eight primitive types in Java
  2. What are integer types in Java
  3. Java floating point types

Java eight primitive types

Java defines eight primitive types of data: byte, short, int, long, char, float, double, and boolean.

Primitive TypeReserved WordSizeMin ValueMax Value
BooleanbooleanN/AN/AN/A
Characterchar16-bitUnicode 0Unicode 216 - 1
Byte integerbyte8-bit-128+127
Short integershort16-bit-215+215 - 1
Integerint32-bit-231+231 - 1
Long integerlong64-bit-263+263 - 1
Floating-pointfloat32-bit1.4e-0453.4e+038
Double precision floating-pointdouble64-bit4.9e-3241.8e+308

byte, short, int, and long are for whole-valued signed numbers. float and double are fractional precision numbers.

char represents symbols in a character set, like letters and numbers. boolean represents true/false values.

Java Integers

Java defines four integer types: byte, short, int, and long.

Integer types are signed and can have positive and negative values.

The width and ranges of these integer types vary widely:

NameWidthRange
long64-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
int32-2,147,483,648 to 2,147,483,647
short16-32,768 to 32,767
byte8-128 to 127

Floating Point Types

There are two kinds of floating-point types: float and double. float type represents single-precision numbers. double type stores double-precision numbers.

Floating-Point Types width and ranges are shown here:

NameWidth in BitsApproximate Range
double644.9e-324 to 1.8e+308
float321.4e-045 to 3.4e+038

Next chapter...

What you will learn in the next chapter:

  1. What is Java boolean type
  2. Values for Java boolean type
  3. Literals for Java boolean type
  4. Java Boolean class
  5. Example - Java boolean type
  6. Example - How to create boolean Literals
Home »
  Java Tutorial »
    Java Langauge »
      Java Data Types
Java Primitive Data Types
Java boolean type
Java char type
Java char value escape
Java byte type
Java short type
Java int type
Java long type
Java float type
Java double type
Java String type
Java String Escape
Java String Concatenation