This is redundant, but I find it clearer.
The same goes for:
int var = 0;
vs.
int var;
I did not do it:
Default values
It is not always necessary to assign a value when declaring a field. Fields declared but not initialized will be set to a reasonable default compiler. Generally speaking, this default value will be zero or null, depending on the data type. Based on such default values, however, the style is usually considered poor programming.
The following table shows the default values for the above types.
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
( Source )
However, as follows from the comments, if it is a local variable, it must be initialized.
source share