Variable
The JVM assigns the default value (the default) to the class's instance and static variables, including every element in the array arrays-without having to write the initialization assignment statement again.
Remember: Local variables have no default values and must be initialized manually!
This default assignment process is done before the object's constructor call, and if the program writes an initial value statement for the instance and static variables, and the values given are the JVM default values, then it is definitely the superfluous and repetitive work.
As the following code illustrates how to gild the lily:
Situation One:
public class Foo {
private int count=0; Extra
private static Boolean dd=false; Extra
Public Foo ()
{
Super ();
}
}
Situation Two:
public class Foo {
private int count;
private static Boolean DD;
Public Foo ()
{
Super ();
count=0; Extra
Dd=false; Extra
}
}
The default values for a variable or object reference are as follows:
int:0
byte:0
long:0
shor:0
float:0.0
double:0.0
Boolean:false
Char: ' \u0000 '
Object Reference:null