O'Reilly logo

Special Edition Using Java™ 2 Enterprise Edition by Mark Wutka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Examining Objects at Runtime

The Reflection classes, for the most part, represent parts of a class. The main classes, found in the java.lang.reflect package, are Field, Method, Constructor, Modifier, and Array. There are also some other support classes that you will learn about shortly. You access the Reflection classes through a Class object, which you can get by calling either Class.forName or getClass on an object.

Listing 39.1 defines a simple Person class that can be used to demonstrate Reflection.

Code Listing 39.1. Source Code for Person.java
 package usingj2ee.reflect; public class Person implements java.io.Serializable { public String firstName; public String middleName; public String lastName; public Person() { } public Person(String ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required