Primitive data types are the most basic data types available within the Java language. There are 8 types of primitive data types : boolean, byte, char, short, int, long. float and double.
These primitive types have predefined operations in Java type system and no new operations can be defined on them.
Details of primitive data types are as follows:
These primitive types have predefined operations in Java type system and no new operations can be defined on them.
Details of primitive data types are as follows:
Category | Types | Size (bits) | Minimum Value | Maximum Value | Precision | Example |
---|---|---|---|---|---|---|
Integer | byte | 8 | -128 | 127 | From +127 to -128 | byte b = 65; |
char | 16 | 0 | 216-1 | All Unicode characters | char c = 'A'; | |
short | 16 | -215 | 215-1 | From +32,767 to -32,768 | short s = 65; | |
int | 32 | -231 | 231-1 | From +2,147,483,647 to -2,147,483,648 | int i = 65; | |
long | 64 | -263 | 263-1 | From +9,223,372,036,854,775,807 to -9,223,372,036,854,775,808 | long l = 65L; | |
Floating-point | float | 32 | 2-149 | (2-2-23)·2127 | From 3.402,823,5 E+38 to 1.4 E-45 | float f = 65f; |
double | 64 | 2-1074 | (2-2-52)·21023 | From 1.797,693,134,862,315,7 E+308 to 4.9 E-324 | double d = 65.55; | |
Other | boolean | 1 | -- | -- | false, true | boolean b = true; |
void | -- | -- | -- | -- | -- |
< and > can be used to compare primitive data types. Comparison using these operators cannot be done for abstract data type like string , list, map.
Abstract data types:
The other type of data type is abstract data type. They are called abstract because their implementation is hidden. The combination of data along with its method is called abstract data type.
In general, there are many possible operations that could be defined for each ADT; however, they often fall into these categories:
- initialize
- add data
- access data
- remove data
Examples are: List, Stack, Queue, Set, Map, etc.
No comments:
Post a Comment