"Reading notes" Java Core technology-the basics-reflection

Source: Internet
Author: User

Running a Java program in a Web page is called an applet.

Reflection

This feature is used extensively in JavaBeans, which is the architecture of Java components.

A program capable of analyzing classes is called reflection (reflective). The function of the reflection mechanism and its powerful, as can be seen below, the reflection mechanism can be used to:

  • Ability to analyze classes in the run
  • View objects in the run, for example, write a tostring method for use by all classes.
  • Implementing the array manipulation code through
  • Using Method objects

The main user of reflection is the tool constructor.

class, during a program run, the Java Runtime system always does not have all objects maintained by a chant called Runtime type identity. This information tracks the classes that each object belongs to. The virtual machine uses the run-time type information to select the appropriate method to execute.
The class that holds this information is called the GetClass () method in the Class,object class and returns an instance of class type.
GetName (): Get class Name
Forname (): Gets the class object that corresponds to the category name
Newinstance (): Quickly create an instance of a class.

"Reading notes" Java Core technology-the basics-reflection

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.