Burt Reynolds Burt Reynolds - 4 months ago 9
Java Question

Why are classes considered reference types?

I am a beginner programmer and have a question. My book says classes are examples of references types and I am a little confused by this. I know their objects created from them certainly would be, but why would the class itself be a reference type?

Answer

I know their objects created from them certainly would be, but why would the class itself be a reference type?

Objects created from classes are reference objects, while classes themselves are reference types.

However, classes themselves have a run-time representation presented to programmers in the form of an instance of a class called Class. This makes classes reference objects, in addition to being reference types.