Data types define the values a variable can hold in its lifetime. There are basically two types of data types available in Java:
- Primitive data types: Primitive data types are the most basic data types that hold a scalar value. It includes boolean, char, short, int, byte, long, float, and double.
- Non-primitive (Reference) data types: Non-primitive data types are created by programmers that hold an object. It includes Arrays, Classes, and Interfaces.
| Data Type | Size(in Bytes) | Default Value |
|---|---|---|
| byte | 1 | 0 |
| short | 2 | 0 |
| int | 4 | 0 |
| long | 8 | 0 |
| float | 4 | 0.0 |
| double | 8 | 0.0 |
| char | 2(UNICODE) | '\u0000' |
| boolean | depend on JVM | false |
- The formula for Signed data type: -2n-1 to 2n-1-1
- The formula for Unsigned data type: 0 to 2n-1
- All integer and floating-point data types are Signed.
- All character data type is unsigned.





















Trends is an amazing magazine Blogger theme that is easy to customize and change to fit your needs.