What type of data you are going to be stored or process on data. that type of described by the datatypes. in java having total 9 types of datatypes with in that 8 are primitive types and another one is reference type.
8 Primitive Types
byte,short,int,long,char,float,double,boolean.
byte: The byte data type is an 8-bit integer. It's value range is -128 to 127. The byte data type can be useful for saving memory in large arrays.
short: The short data type is a 16-bit integer.It's value range is -32,768 to 32,767.
int: The int data type is a 32-bit integer. It's value range is -2,147,483,648 to 2,147,483,647.
long: The long data type is a 64-bit integer. It's value range is
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Use this data type when you need a range of values larger than int range values.
float: The float data type is a single-precision 32-bit floating point.
double: The double data type is a double-precision 64-bit floating point.
boolean: The boolean data type has only two possible values: true and false.
char: The char data type is a single 16-bit Unicode character. It has a minimum value of '\u0000' and a maximum value of '\uffff'
in primitive types if you are not assign the values to variables compiler automatically set it's default values.
Default values for primitive types
byte : 0
short : 0
int : 0
long : 0L
float : 0.0f
double : 0.0d
char : '\u0000'
boolean: false
Reference Type
reference types are don't have any specific range it's memory allocated dynamically.
reference type default value is null.
No comments:
Post a Comment