Possible Duplicate:
Does Java guarantee that Object.getClass() == Object.getClass()?
If I have a class such as
Class<? extends MyObject> aClass = ...;
can I then do:
if (aClass == MySubObject.class) { ... }
or do I have to do
if (aClass.equals(MySubObject.class)) { ... }
In addition, further to knowing the answer, I would love to know a reference i.e. where this is defined.
I prefer to use ==
if possible, because I find it more readable, and faster. (Obviously it's not that much more readable, or that much faster, but still, why use a more complex solution if a simpler solution is available.)