There are eight data types supported by Java.
Primitive data types are predefined by java and named by a keyword.
byte:
- · It is 8-bit integer.
- · Range:- Minimum value is -128 (2^7) Maximum value is 127 (2^7 -1)
- · Default value is 0.
- · Example: byte a = 100 , byte b = -50
short:
- · It is a 16-bit Integer.
- · Range:- Minimum value is -32,768 (-2^15) Maximum value is 32,767 (2^15 -1)
- · Default value is 0.
- · Example: short a = 15000, short b = -15000
int:
- · Int data type is a 32-bit integer.
- · Range:- Minimum value is - 2,147,483,648.(-2^31) Maximum value is 2,147,483,647(2^31 -1)
- · The default value is 0.
- · Example: int a = 100000, int b = -200000
long:
- · Long data type is a 64-bit integer.
- · Range:- Minimum value is -2^63 Maximum value is 2^63 -1.
- · Default value is 0L.
- · Example: long a = 100000L, long b = -200000L
float:
- · Float data type is a single-precision 32-bit IEEE 754 floating point.
- · Default value is 0.0f.
- · Example: float f1 = 234.5f
double:
- · double data type is a double-precision 64-bit IEEE 754 floating point.
- · Default value is 0.0d.
- · Example: double d1 = 123.4
boolean:
- · boolean data type represents one bit of information.
- · Only two possible values: true and false.
- · Default value is false.
- · Example: boolean one = true
char:
- · char data type is a single 16-bit Unicode character.
- · Range:- Minimum value is '\u0000' (or 0) Maximum value is '\uffff' (or 65,535 inclusive).
- · Example: char letter ='A'
No comments:
Post a Comment