Basic JAVA 2
Data Types in Java
Java language has a rich implementation of data types. Data types specify size and the type of values that can be stored in an identifier
In java, data types are classified into two catagories:
1) Primitive Data type
2) Non-Primitive Data type
1) Primitive Data type :
A primitive data type can be of eight types :
char boolean byte short int long float double
A primitive data type can be of eight types :
Once a primitive data type has been declared its type can never change, although in most cases its value can change. These eight primitive type can be put into four groups:
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 |
2) Primitive Data type :
A reference data type is used to refer to an object. A reference variable is declare to be of specific and that type can never be change. We will talk a lot more about reference data type later in Classes and Object lesson.For example, Employee, Puppy etc:
Class objects, and various type of array variables come under reference data type. Default value of any reference variable is null.
Example: Animal animal = new Animal("tiger");
No comments:
Post a Comment
Hai , Post your comment . (required, Bugs, Errors )