Java Data Types in Hindi
Definition of Java Data types in Hindi
“Java Data types is a spacial keyword used to allocate sufficient memory space for the data, in other words Java Data types is used for representing the data in main memory (RAM) of the computer”
In general every programming language is containing three categories of data types. They are
- Fundamental or primitive data types
- Derived data types
- User defined data types
- Primitive Data types:- to represent numbers.
There are two types of primitive data type in Java
Integral Datatype:- byte,short,int,long
Floating-Point Datatype:- float,double
- Char Datatype :– to represent characters. For Example, char JavaGuide
- Boolean Datatype:– to represent logical value. For Example , boolean true
Integral Data Types in Java
size:- 8 bits 1 byte
Maximum Value:- 127
Minimum Value:- -128
Range:- -128 to 127
MSB- most significant bit is called “sign bit”. 0 means +tive value and 1 means –tive value.
byte g = 117; //right
byte g = 127; //right
byte g = 131; //wrong compile time error
byte g = 127.89; //wrong compile time error
byte g = true; //wrong compile time error
byte g = ”JavaGuide”; //wrong compile time error
2) short :-
Most rarely used data type in java is short.
This data type is best For 16 bit processor.
Now a days 16 bit processor outdated & hence short data type is also outdated.
range:- [-32768 to 32767] -215 to 215-1
short g = 32767; //right
short g = -32767; //right
short g = 32768; //wrong compile time error
short g = 123.456; //wrong compile time error
short g = true; //wrong compile time error
3) int :-
most commonly used data type is int.
In C – Language data type varied from platform to platform.
Means for 16 bit processor it is 2 bytes and 32 bit processor it is 4 bytes.
Advantage:- This approach will helpful for read & write purpose.
Disadvantage:-chances of failing program very high.
Size:- 4 bytes
Range:- [-2147483648 to 2147483647] -231 to 231-1
But in java language size will be 4 bytes for any platform.
Advantage:- Chances of failing program is very less. Because java is robust language.
Disadvantages:- read & write operation will become costly & performance will be reduced.
Whenever int data type is not enough to hold big value that time we should go for long data type.
To represent big value like lacks and corer value.
Size:- 8 bytes
Range:- -263 to 263-1
Note:- All above data types ment for representing numerical value
For represent real number compulsory we should go for floating point data type.
Range:- -3.4e38 to 3.4e38
For 5 to 6 decimal place accuracy we should go for float.
float follows single precision.
Range:- -1.7e308 to 1.7e308
For 14 to 15 decimal place we should go for double.
double follows double precision.
Go4Vidhya- you may like to check Features of Java in Hindi