Home Exam Help ICT Tutorials Government Jobs General Knowledge Courses Health Travel

This tutorial covers Java data types. For the continued discussion, see Part 2.

Primitive Data Types

Java has eight primitive data types:

TypeSizeRange / Description
byte1 byte-128 to 127
short2 bytes-32,768 to 32,767
int4 bytes-2,147,483,648 to 2,147,483,647
long8 bytesVery large integers
float4 bytesDecimal numbers (single precision)
double8 bytesDecimal numbers (double precision)
char2 bytesSingle character (Unicode)
boolean1 bittrue or false

Reference Data Types

Reference types include classes, interfaces, and arrays. The most commonly used reference type is String. Unlike primitives, reference variables store the memory address of the actual data.

String name = "LankaTricks";
int[] numbers = {1, 2, 3, 4, 5};

Next: Java Data Types Part 2 | Related: Wrapper Classes