Best Java Training
chennai
By
accordittraining.com
DATA TYPES IN JAVA
Types
They are classified into two types:
• Primitive Data Type
• Non-Primitive Data Type
Primitive Data Type
They are classified into 8 types,they are:
1. Byte
2. Short
3. Int
4. Long
5. Float
6. Double
7. Boolean
8. Char
Non-Primitive Data Type
It can be classified into 2 types,they are:
1. String
2. Array
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’;
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”;
CONTACT US
Call us +91 9940289059
www.accordittraining.com
Email:enquiry@accordittraining.com

Data types in java