Chapter 3-3 Flashcards
Two types of data types in Java
- Primitive data types
- Non-primitive data types
include boolean, char,
byte, short, int, long, float and double.
Primitive data types
include
Classes, Interfaces, and Arrays.
Non-primitive data types
Primitive data types:
a) Boolean data type
b) Byte Data Type
c) Short Data Type
d) Int Data Type
e) Long Data Type
f) Float Data Type
g) Double Data Type
h) Char Data Type
This data type is used for simple flags that track true/false conditions
Boolean data type
is used to save memory in large arrays where the memory
savings is most required.
It is an 8-bit signed two’s complement integer. Its value-range lies between -128 to
127 (inclusive).
Byte Data Type
is a 16-bit signed two’s complement integer. Its value-range lies
between -32,768 to 32,767 (inclusive).
Short Data Type
is generally used as a default data type for integral values unless if
there is no problem about memory.
is a 32-bit signed two’s complement integer
Int Data Type
is a 64-bit two’s complement integer.
is used when you need a range of values
more than those provided by int.
Long Data Type
is a single-precision 32-bit IEEE 754 floating point.
It is recommended to use a float (instead of double) if you need to save memory in
large arrays of floating point numbers.
Float Data Type
is a double-precision 64-bit IEEE 754 floating point.
is generally used for decimal values just like float
Double Data Type
is a single 16-bit Unicode character.
is used to store characters.
Char Data Type