BCA / B.Tech 9 min read

Data Types in Java

Data Types in Java:

Data types specify the different sizes and values that can be stored in a variable. In Java, data types are divided into two main categories:

1. Primitive Data Types:
These are the most basic data types and are not objects. They store the actual value directly. Java has 8 primitive types:
  • Numeric Types:
    • Integer types: `byte` (8-bit), `short` (16-bit), `int` (32-bit), `long` (64-bit).
    • Floating-point types: `float` (32-bit), `double` (64-bit).
  • Character Type: `char` (16-bit Unicode character).
  • Boolean Type: `boolean` (`true` or `false`).

2. Non-Primitive (Reference) Data Types:
These data types refer to objects. Unlike primitive types, they do not store the actual object but a reference (memory address) to where the object is stored. Non-primitive types include Classes, Interfaces, Strings, and Arrays. They are created by the programmer (except for String and Array).