a.getClass()
returns the runtime type ofa
. I.e., if you haveA a = new B();
thena.getClass()
will return theB
class.A.class
evaluates to theA
class statically, and is used for other purposes often related to reflection.
What is the difference between a.getClass() and A.class in Java?
@reference_2_docs.oracle.com
Retrieving Class Objects
@reference_3_coderanch.com
Overriding Vs Hiding
Foo f = new Bar();
f.getClass().getMethod("classMethod", new Class[]).invoke(null, new Object[]);
No comments:
Post a Comment