Understanding of Java's Rtti and reflection

Source: Internet
Author: User

Recently in read thinking in Java this book. When I read the type information, I started to mix up the Rtti and reflections in the book, and I don't know what the connection is, what the similarities and differences are. So on the Internet and find some content auxiliary understanding, this chapter again read again, to the above questions have their own answer, think of Rtti and reflection, the mind has its own outline.

They both have the same purpose:

At run time, information about objects and classes is recognized.

Same point:

The same purpose;

Functions are implemented through class classes.

Different points:

RTTI: (primarily in polymorphic, such as parameter passing) it assumes that we already know all types at compile time and will open and inspect all. class files. For example: in polymorphic parameter passing, the base class and the derived class are opened and checked.

Reflection:. Class is not available at compile time, so the. class file is opened and checked at run time.

Noun Explanation:

Rtti:runtime type identification, run-time types identification.

Class: Classes of classes; class type; For example, an object dog dog, [Dog.class,dog.getclass (), Class.forName (dog)] are objects of class type. Role: One is how the type information of an object is represented at run time and is a special object through class.

Understanding of Java's Rtti and 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.