Menu
Coddy logo textTech

Primitive Data Types

Lesson 1 of 16 in Coddy's Strings and Arrays in Java course.

Before we dive into the course, let's clarify data types in Java.

Data types are divided into two groups:

  • Primitive data types
  • Non-primitive data types

Primitive data type specifies the size and type of variable values, and it has no additional methods.

The primitive data types in Java are byte, short, int, long, float, double, boolean and char.
 

Data TypeSizeDescription
byte1 byteWhole numbers from -128 to 127
short2 bytesWhole numbers from -32,768 to 32,767
int4 bytesWhole numbers from -2,147,483,648 to 2,147,483,647
long8 bytesWhole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
float4 bytesFractional numbers up to 6 to 7 decimal digits
double8 bytesFractional numbers up to 15 decimal digits
boolean1 bittrue or false values
char2 bytesSingle character/letter
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

Try it yourself

This lesson doesn't include a code challenge.

All lessons in Strings and Arrays in Java