3.2 Data type
Every variable in Java has a data type. Data types specify the size and type of values that can be stored.
Data types in Java divided primarily in two tyeps:
Primitive(intrinsic) and Non-primitive.
Primitive types contains Integer, Floating points, Characters, Booleans And Non-primitive types contains Classes, Interface and Arrays.
Integer:This group includes byte, short, int and long, which are whole signed numbers.
Floating-point Numbers: This group includes float and double, which represent number with fraction precision.
Characters: This group includes char, which represents character set like letters and number
Boolean: This group includes Boolean, which is special type of representation of true or false value.
Some data types with their range and size:
byte: -128 to 127 (1 byte)
short: -32,768 to +32,767 (2 bytes)
int: -2,147,483,648 to +2,147,483,647 (4 bytes)
float: 3.4e-038 to 1.7e+0.38 (4 bytes)
double: 3.4e-038 to 1.7e+308 (8 bytes)
char : holds only a single character(2 bytes)
boolean : can take only
true or false (1 bytes)
No comments:
Post a Comment