Monday, March 21, 2011

JAVA Programming : Data Types

JAVA Data Types


Java has a number of data types below is the complete list of them . Although syntax of Java is largely derived from C++ but datatypes are a bit different from C for example C does not have Boolean data type. Java Datatypes have a fixed size and also some default values that will bet set to variables if they are declared but not initialized.

  • Boolean : Boolean datatype does not have a specific size declared but conceptually it has one bit value. Boolean datatypes has only two possible values true or false. Default value for Booleans are false.
    Size:- not defined 
    Values:- true or false 
    Default value:- false
  • Char: A char is 16 bit value that can be treated like an integer value but is intended to hold characters. In a Java program a char datatype is always interpreted as a numeric value of a displayable character. 
    Size:- 16 bit
    Values:- from 0 to 65535
    Default value:- 0
  • Byte: A byte is an 8 bit integer value.
    Size:- 8 bit
    Values:- from -128 to 127
    Default value:- 0
  • Sort: A sort is an 16 bit integer value.
    Size:- 16 bit
    Values:- from -32768 to 32767 
    Default value:- 0
  • Int: A int is an 32 bit integer value.
    Size:- 32 bit
    Values:- from -2147483648 to 2147483647
    Default value:- 0
  • long: A Long is an 64 bit integer value and it is the largest of all the integer types. 
    Size:- 64 bit
    Values:- from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
    Default value:- 0
  • float: A float is 32 bit single precision floating point decimal number.
    Size:- 32 bit
    Values:- from -1.4E-45 to 3.4028235E38 
    Default value:- 0.0
  • double: Double is 64 bit double precision floating point decimal number.
    Size:- 64 bit
    Values:- from -4.9E-324 to 1.7976931348623157E308 
    Default value:- 0.0

No comments:

Post a Comment