What are primitive types in java?
Java primitive types are not reference types / objects. Java supports 8 primitive data types. Each primitive type has a range of values. They are broadly classified as
- Numeric – which are sub classified as - byte, short, int, long, float and double
- Character - char
- Boolean - boolean.
All numeric data types are signed and there are no unsigned numeric data types. The size of each data type does not change from one architecture to that of another.
Due to this property, Java is so portable. The entire range of values of a specific data type occupies same amount of memory space.
What are primitive types in java?
Data Type | Default Value (for fields) | Size |
byte | 0 | 8-bit signed |
short | 0 | 16-bit signed |
int | 0 | 32-bit signed |
long | 0L | 64-bit signed |
float | 0.0f | single-precision 32-bits |
double | 0.0d | double-precision 64-bit |
char | '\u0000' | 16-bit Unicode character |
String | null | |
boolean | false | not precisely defined |