Like what:
Public Maingame Mmaingame; With public maingame mmaingame = null; the difference between the two sentences?
Compile time will be different, unassigned, directly using the compile will be an error.
Without assigning space, assigning null allocates the initial space of 0 size.
The local variable is assigned the initial value, the global variable does not need to be assigned the initial value, and the int a=null; this sentence should be an integer a=null;
If you declare a variable in a class that can not be assigned a value, you get the default value when you construct the object
If you declare a variable in a method, you must assign an initial value
As a member variable, int A; the default value is 0, but int a=null; in Java this is not true; int is the basic type;
Only the default value of the package type Integer is null so you can write int a;(0) Integer A; (null)
The object reference in Java is placed on the stack, the instance of the object is placed in the heap, and if NULL, the description is only in the stack.
The first thing to understand is that when the object in Java is passed, it is a reference (that is, the object's address), which is much more efficient than passing the whole object. The underlying type, int,double, and so on, is the value that is passed. For example, (new arraylist<string>). Add (new string ("Hello")), the JVM simply deposits the address of the new string ("Hello") into the list of lists. String str = new String ("Test"), is the opening up of memory into the object and assigns its reference to Str. Similarly, BookInfo bookinfo=null and BookInfo bookinfo=new BookInfo (): The former, is the declaration of an object (the reference), the JVM does not open up memory into an object, and the latter, after declaring a reference to an object, He was assigned the address of the newly opened object that did not store any valid values.
In Java, only one object is declared that is not assigned a value, and the difference between declaring an object and assigning null