Data Types in Java
Posted by
Ravi Kumar at Sunday, March 1, 2009
Share this post:
|
In java every variable must have a declared data type. Java defines eight simple types of data. They are
byte,short,int,long,char,float,double and boolean.
These can be put in four groups:
1.Integer: This group includes byte,short,into and long, which are for whole-valued signed numbers.
Type Storage Requirement Range
2.Floating-point numbers: This group includes float and double, which represent numbers with fractional precision.
3.Characters: This group includes char, which represents symbols in a character set, like letters and numbers.
4.Boolean: This group includes boolean, which is a special type for representing true/false values.
Type Storage Requirement Range:
Int: 4 bytes -2,147,483,648 to 2,147,483, 647 (just over 2 billion)
Short: 2 bytes -32,768 to 32,767
Long: 8 bytes -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Byte: 1 byte -128 to 127
Float: 4 bytes approximately ±3.40282347E+38F (6–7 significant decimal digits)
Double: 8 bytes approximately ±1.79769313486231570E+308 (15 significant decimal digits)