AlgoMaster Logo

Inspecting Classes

Last Updated: June 6, 2026

Medium Priority
24 min read

Once a Class object is available, the next question is what it can answer. The reflection API exposes a rich vocabulary for reading a type's structure: its fields, its methods, its constructors, the modifiers on each, the annotations attached, and the relationships to its superclass and interfaces. This lesson covers only the read-only side of that vocabulary.

The model is simple. Every member a class can have (field, method, constructor) has a matching reflection object (Field, Method, Constructor) that describes it. Asking a Class for these objects is the way to walk the structure. This lesson builds a small describe() utility that takes any class and prints what it contains, using a small e-commerce class hierarchy (Product, Order, Cart, Customer) as the running example.

Premium Content

Subscribe to unlock full access to this content and more premium articles.