Java Primitive Types

Introduction

Java has eight primitive types:

  • byte
  • short
  • int
  • long
  • char
  • float
  • double
  • boolean

The primitive types are also referred to as simple types.

These eight primitive types can be put in four groups:

Group Name Description
Integersincludes byte, short, int, and long, which are for whole-valued signed numbers.
Floating-point numbers includes float and double, which represent numbers with fractional precision.
Characters includes char, which represents symbols in a character set, like letters and numbers.
Boolean includes boolean, which is a special type for representing true or false values.

The primitive form the basis for all other types of data that you can create.

The primitive types represent single values-not complex objects.

Although Java is otherwise completely object-oriented, the primitive types are not.

All Java data types have a strictly defined range.

For example, an int is always 32 bits, regardless of the particular platform.




PreviousNext

Related