Data Types
Java language has rich implementation of data types.Data type specify the size
and value that can be stored in an identifier.
In java data types are specified into two category :-
- Primitive Data Type
- Non-Primitive Data Type
A primitive Data types can be of eight types:-
- char
- boolean
- byte
- short
- int
- long
- float
- double
Note : -Once a primitive datatype has been declared, its type can never change,although its value can change in most of cases
| Data Type | Default Value | Default size |
|---|---|---|
| boolean | false | 1 bit |
| char | '\u0000' | 2 byte |
| byte | 0 | 1 byte |
| short | 0 | 2 byte |
| int | 0 | 4 byte |
| long | 0L | 8 byte |
| float | 0.0f | 4 byte |
| double | 0.0d | 8 byte |
Non-primitive datatype - It is also known as reference data type. Reference
data type is used to refer an object. A reference variable is declared to be specific and that type can never be changed.
No comments:
Post a Comment