Monday 11 January 2016

DATATYPES IN JAVA

Java language has a rich implementation of data types. Data types specify size and the type of values that can be stored in an identifier.
There are two types of data types in java.

  1. Primitive Data Type
  2. Non-Primitive Data Type
1.Primitive Data Type
 A primitive data type can be of eight types :
  1. The char:It is a single 16-bit uni code character.The minimum value is 0.It is used to store any character.Example:char letterC='C'.
  2. The byte:It is 8 bit integer data type. Value range from -128 to 127. Default value zero.example:byte b=11; 
  3. The short:It is 16 bit integer data type. Value range from -32768 to 32767. Default value zero. example:short s=15;
  4. The int: It is 32 bit integer data type. Value range from -2147483648 to 2147483647. Default value zero. example:int i=10;
  5. The long:It is 64 bit integer data type. Value range from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Default value zero. example:long l=10001;
  6. The float:It is 32 bit float data type. Default value 0.0f. example:float ff=10.5f;
  7. The double:It is 64 bit float data type. Default value 0.0d. example:double db=10.266
  8. The Boolean:This data type represent one bit of information.there are only two possible values:True and False. example: boolean one=True;
2.Non-Primitive Data Type
A reference data type is used to refer to an object. A reference variable is declare to be of specific and that type can never be change.



No comments:

Post a Comment