Why Java uses reflection (easy-to-understand examples)

Source: Internet
Author: User

The greatest benefit of Java reflection is the ability to get the structure, member variables, and instantiation of a class during run time.
The following are specific usage scenarios: if we had two programmers, a programmer would need to use the class written by the second programmer while writing the program, but the second programmer did not complete the class he wrote. So can the first programmer's code be compiled? This is not possible by compiling. Using the mechanism of Java reflection, the first programmer can compile the code without getting the class that the second programmer wrote. The reflection mechanism of Java it knows the basic structure of the class, this ability to explore Java class structure, we call Java class "self-audit". Everyone has used JCreator and eclipse. When we build an object, we call the method and properties of the object. At the click of a point, the compilation tool automatically lists all the methods and properties that the object can use for the user to select. This is the use of the principle of Java reflection, is to create the object of our discovery, self-examination.

Excerpted from https://zhidao.baidu.com/question/1435999620760135379.html

Why Java uses reflection (easy-to-understand examples)

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.