Sunday, May 3, 2020

Data Types in Java

Primitive data types: There are 8 primitive data types. i.e. boolean, byte, char, short, int, long, float, double.

Non-primitive data types: The non-primitive data types are String, Arrays and user define Classes and Interfaces.




Data Type Default Value Default size
boolean FALSE 1 bit
char \u0000' 2  byte
byte 0 1  byte
short 0 2  byte
int 0 4 byte
long 0L 8 byte
float 0.0f 4 byte
double 0.0d 8 byte


Data type Casting or Type Conversion: There are two type of data type casting. Either implicitly or explicitly. Click here to read in details.
  • Implicit Data type Casting: This type casting occurs while we want to convert small data type to big data type for example in to long. This type of casting happens automatically.
  • Explicit Data type Casting: This type casting occurs while we want to convert big data type to small data type for example long to int.



Related Tutorials:


No comments:

Post a Comment