16.3 The Class Class
Let’s suppose we want to write a class browser. This program should display all classes belonging to the running program and furthermore additional information, such as variable assignment, declared methods, constructors, and some information about the inheritance hierarchy. For this purpose, you’ll need the library class, class . Instances of Class are objects that, for example, represent a Java class, record or a Java interface.
In this respect, Java differs from many conventional programming languages because the members of classes can be queried by the currently running program using the Class objects. The instances of Class are a restricted kind of meta-object [ 208 ]—containing the description of a Java type but ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access