Object.getClass
does not need to be invoked on an instantiated object JAVA-W0077This method allocates an object just to call getClass()
on it, in order to retrieve the Class
object for it. It is simpler to just access the static .class
property of the class itself.
Class<SomeClass> c = new SomeClass().getClass();
Class<SomeClass> c = SomeClass.class;
Just use the static .class
property when you can statically determine the class object you need.