When we create a new object, Java will apply for a memory area in Heap to store the class data. The member variables are the data of the class and are also placed in this memory area. When we do not initialize the variable, the data in the Heap has no reference. At this time, if this variable is used elsewhere in the program, a null pointer exception will be thrown!
In fact, only basic types have default values, mainly to prevent null pointer exceptions. User-defined types need to be initialized by the user
Only class variables have default values and do not need to be initialized manually
When we create a new object, Java will apply for a memory area in Heap to store the class data. The member variables are the data of the class and are also placed in this memory area. When we do not initialize the variable, the data in the Heap has no reference. At this time, if this variable is used elsewhere in the program, a null pointer exception will be thrown!
Maybe he needs a clean object. Wiping it clean every time is very tiring. . . (nonsense)