Translate

Data Types in JAVA.

Data Types in JAVA

  • It is a type of data which is used in the program.
  • There are many predefined data types in java library like int,char,float etc.

Type of Data Type

Primitive Data Type

  • The data type which is predefined in the library is called primitive data type.
  • It is named by a keyword for example int,float,char etc.
  • There are eight primitive data types in java.
    byte, short, int, long, float, double, boolean and char.

Integer Type

TypeSize in bytesRange
byte1-128 to 127
short2-32,768 to 32,767
int4-2,147,483,648 to 2,147,483,647
long8-9,223,372,036,854,775,808 to 9,223.372,036,854,775,808

Float Type

TypeSize in bytesRange
float43.4e-038 to 3.4e+038.
double81.7e-308 to 1.7e+038.

Boolean

Keywordboolean
Syntaxboolean x;
ValueTrue/False
DefaultFalse

Character

Keywordchar
Syntaxchar x;
Value'a','@','9'
Range0 to 65536

Non-primitive Data Type

  • The data type which is derived from primitive data type is called non-primitive data type.
  • It is also called reference data type.
  • They don't store the value, but store a reference to that value.
  • Example:Array,class,interface etc.
Next Post Previous Post
No Comment
Add Comment
comment url