From the object's reference to the reflection mechanism passed to Java

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.