How do you get and check an object's type in Java, as you can using 开发者_Python百科Type t = obj.GetType();
in C#?
Try getClass()
. It returns the runtime class of the object.
Class clazz = obj.getClass();
.getClass()
..
Isn't it fair to actually answer Class<?>
?
Returns: The Class object that represents the runtime class of this object.
精彩评论