Java defines 8 primitive types:
byte
- Smallest integer type
- It is a signed 8-bit type (1 Byte)
- Range is -128 to 127
- Especially useful when working with stream of data from a network or file
- Example: byte b = 10;
short
- short is signed 16-bit (2 Byte) type
- Range : -32768 to 32767
- It is probably least used Java type
- Example: short vId = 1234;
int
- The most commonly used type
- It is signed 32-bit (4 Byte) type
- Range: -2,147,483,648 to 2,147,483,647
- Example: int a = 1234;
long
- long is signed 64-bit (8 Byte) type
- It is useful when int type is not large enough to hold the desired value
- Example: long soconds = 1234124231;
char
- It is 16-bit (2 Byte) type
- Range: 0 to 65,536
- Example: char first = ‘A’; char second = 65;
float
- It is 32-bit (4-Byte) type
- It specifies a single-precision value
- Example: float price = 1234.45213f
double
- It uses 64-bit (8-Byte)
- All math functions such as sin(),cos(),sqrt() etc… returns double value
- Example: double pi = 3.14141414141414;
boolean
- The boolean data type has only two possible values: true and false.
- This data type represents one bit of information, but its "size" isn't something that's precisely defined.
Download the Android app to get all Government Job Notifications on your Mobile.
Download Now
Important: Please always Check and Confirm the above details with the official Advertisement / Notification.