JAVA variable initial values

Be sure to initial value when you define a variable java? For example, public class Test {int x; // Will have to give x initial value it? The int x = 9}

 

 

Of course, to the initial value, however, class variables have a default initial value, and therefore can not write, int default initial value is 0, boolean is false, the object is null
local variables (Method Lane variable) is not the default initial value in
the first before being used must be assigned.

Guess you like

Origin blog.csdn.net/ll148305879/article/details/94475773