The Class Whose Name Is Class

Here's where the terminology admittedly can get a little confusing. We saw a few pages back that every object has some Run Time Type Information associated with it. The RTTI for any object is stored in an object whose class is called “Class.” Class could certainly use a better, less self-referential name, like ClassInformation or just RTTI.

A big use of Class is to help with loading new classes during program execution. A lot of other languages load an entire program before they start execution. Java encourages dynamic loading. Classes only need to be loaded on demand when they are first referenced.

When you compile a class called, say, Fruit, the compiler creates the bytecode file Fruit.class. When the first ...

Get Just Java™ 2 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.