What is the default value of float and double datatype in Java?

Love and Share

Answer:  Default value of float and double datatype in different as compared to C/C++. For float its 0.0f and for double it’s 0.0d

Default Value of Data Types in Java :

Data Type Default Value (for fields)
byte 0
short 0
int 0
long 0L
float 0.0f
double 0.0d
char ‘u0000’
String (or any object) null
boolean false

Love and Share

Leave a Reply

Your email address will not be published. Required fields are marked *