The so-called "understanding" Baizhanbudai, in order to find out the reference pass, first of all to figure out two pieces of memory (that is, stack memory, heap memory)
1. Simple knowledge of stack memory and heap memory
Stack memory: The storage of things, can be understood as an integer variable (only a numeric value), which holds a piece (only a piece) of the memory of the heap memory address value, for the sake of understanding it first as the name of the object!
Heap memory: What is stored can be understood as the specific information of an object, and each block of heap memory is opened with the New keyword
It is not difficult to see how objects are created and allocated in each memory by the following code and diagram
Package Com.shxt.bishi;
Class Book {
String title;
Double Price;
public void Printinof () {
System.out.println ("title:" +title);
System.out.println ("Price:" +price);
}
}
public class testinstant{
public static void Main (string[] args) {
Book book=null;//declaring objects
Book=new book ();//instantiation of an object
Book.title= "Java ideas";//Set properties in a class
book.price=60.0;//setting properties in a class
Book.printinof ();//Call method
}
}
2. Delivery of reference data types
Not to be continued ....
From the object's reference to the reflection mechanism passed to Java