- Primitive Data Type
- Non-Primitive Data Type
Primitive Data Types:
- Byte
- Short
- Int
- Long
- Float
- Double
- Boolean
- Char
Non-Primitive Data Types:
Non-Primitive Data Types are classified into two types. they are:
- Arrays
- Strings
Primitive Data Type:
Byte:
- For Storing whole Numbers
- It stores a value between -128 to 127
- Size = 1 byte
- Value = 0
Short:
- For Storing Whole Numbers
- It stores value between -32,768 to 32767
- Size = 2 byte
- Value = 0
Int:
- For Storing Whole Numbers
- It stores value between -2,147,483,648 to 2,147,483,647
- Size = 4 byte
- Value = 0
Long:
- For Storing Whole Numbers
- It stores value between 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
- Size = 8 byte
- Value = 0
Double:
- It is used for Fractional Numbers
- It stores upto 15 decimal digits
- Size = 8 byte
- Value = 0
Float:
- It is used for Fractional Numbers
- It stores upto 7 decimal digits
- Size = 4 byte
- Value = 0
Boolean:
- It is used to tell either true or false
Char:
- It is used in character
- Size = 2 bytes
For Example:
int i = 10; byte b = 5; short s = 10; long = 123l; float = 23.9f; double = 34.98d; or 34.98 boolean = true; or false; char = ‘A’;
Non-Primitive Data type:
Array:
Array is classified into two types:
- 1.Single-Dimension Array
- 2.Multi-Dimension Array
String:
- String is a collection of character
- It can be initialized into double quotes
For example:
String st=”My Name”;
I hope this will be helpful for the beginners in java ...See you in the Next topic. core java training in chennai
No comments:
Post a Comment