In java, class variables store the object's memory address after initialization, not the object itself, that is, class variables point to the object's memory address. However, in java, you cannot see the memory address of the object. Generally, the "type name @ hexadecimal number" is not the memory address, it is only the hexadecimal representation of the hash code of the object. The java language itself does not provide any way to view the memory address. JVM is used to load class objects. For security and convenience, JVM memory management is transparent to Java application programmers. The following code gives you a general idea about how to store classes:
/*** Comments: class-type storage features * @ author plug-in name * Crete Time: 2013-10-5 **/public class Neicun {public static void main (String [] args) {Neicun [] n = new Neicun [3]; // an array is initialized and System is not initialized for Neicun. out. println (n [0]); // output null n [0] = new Neicun (); // call the constructor to initialize the System. out. println (n [0]); // n [0] points to the memory address, but the output is not the memory address, only the hex representation of the object's hash code. Neicun m = new Neicun (); System. out. println (m); // hexadecimal format of the hash code of the output object }}
The above Code not only illustrates the storage method of the class type, but also reflects another problem: when initializing an array of class types, it does not initialize each variable of the class type in the array, only the size of the array is confirmed, and the corresponding class type variables need to be initialized separately.
This article is from the blog "plug on the name of pigs", please be sure to keep this source http://zuohao1990.blog.51cto.com/6057850/1304854