Data type's in java language



Java is strongly typed language.

Primitive Data Types:

   Java has eight primitive Data types but can be put in four groups.

  1.  Integer
  2. Floating-point
  3. Characters
  4. Boolean

Integer:

Java has four integer types 
  • byte
  •  short
  •  int
  •  long
      All types are signed, positive and negative values.

Name
Width
Range
byte
 8bits
 128 to 127
 short
 16bits
 –32,768 to 32,76
 int
 32bits
 –2,147,483,648 to 2,147,483,647
 long
 64bits
 –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

Floating-point:

Java has  two floating-point types
  • Double 
  • float
 Name
 width
 Approx. Range
 float
 32bits
1.4e–045 to 3.4e+038 
 double
 64bits
 4.9e–324 to 1.8e+308

 Characters:

In Java character data types are use to store character is char. The width is 2 bytes and 16 bits.
The Range is 0 to 65,536. 
In this data type there is no negative char.

 Boolean:

In Java language Boolean data types are used for logical values. It has only two possible values one is true and other is false.
The Range of Boolean datatypes are True and False and the width is not defined.... 

String:

In other language like c/c++ string is implement as a characters of array but in java string is treated as a object types because java implements string as a objects.



Comments

Popular posts from this blog

Inheritance in Java

Operators in Java Language?

Type Casting or Conversion in Java