Its an easy MAP to illiterate, how to cast a java primitive data type to another one by examples
Supported Java Primitive Data Types
byte, short, int, long, float, double, boolean, char in addition to String.
You can click on any cell of below table map to show the code example.
| - | size | Internal Implementation | Default Value | Minimum value | Maximum value | ||
|---|---|---|---|---|---|---|---|
| byte | 8 bit (1 byte) |
Two's complement integer. | 0 | -128 | 127 | 2^7 | |
| short | 16 bit (2 bytes) |
Two's complement integer. | 0 | -32,768 | 32,767 | 2^15 | |
| int | 32 bit (4 bytes) |
Two's complement integer. | 0 | -2,147,483,648 | 2,147,483,647 | 2^31 | |
| long | 64 bit (8 bytes) |
Two's complement integer. | 0L 0l |
-9,223,372,036,854,770,000 | 9,223,372,036,854,770,000 | 2^63 | |
| float | 32 bit (4 bytes) |
Single-precision 32-bit/IEEE 754 floating point. | 0.0F 0.0f |
1.4E-45 | 3.4028235E38 | ||
| double | 64 bit (8 bytes) |
Double-precision 64-bit/IEEE 754 floating point. | 0.0D 0.0d |
4.9E-324 | 1.7976931348623157E308 | ||
| boolean | VM dependent | VM dependent, to store either true of false |
false |
||||
| char | 16 bit (2 bytes) |
Single 16-bit Unicode character. | '\u0000' | \u0000' (or 0) | \uffff' (or 65,535) | ||
| String | null |