Data Types: Primitive Data Type Reference Type (Non -primitive) boolean class byte Array[] char interface short enum int long float double
Java Data Types
Java has two main categories of data types: Primitive Types and Reference Types. Understanding these is fundamental to programming in Java.
Primitive Data Types
Primitive data types are the most basic data types available in Java. They directly hold the value and are stored directly in memory.
| Primitive Data Type | Size | Default Value | |
|---|---|---|---|
boolean |
Undefined | false |
|
byte |
1 byte | 0 |
|
char |
2 bytes | '\u0000' |
|
short |
2 bytes | 0 |
|
int |
4 bytes | 0 |
|
long |
8 bytes | 0L |
|
float |
4 bytes | 0.0f |
|
double |
8 bytes | 0.0d |
Reference Data Types
Reference data types (also known as object types) don't directly store the value. Instead, they store references (addresses) to objects in memory.
For all reference types, the default value is null.
| Reference Type | Default Value |
|---|---|
String |
null |
| Arrays | null |
| Classes | null |
| Interfaces | null |

Comments
Post a Comment