getClass返回的是java.lang.Class的对象,方法描述是:Returns the runtime class of this Object. The returned Class object is the object that is locked by static synchronized methods of the represented class.
就是说,返回的是Class类的对象,所以可以调用Class类的getName方法
所有的类都是Object类的子类,子类调用父类的方法跟是否是静态的有什么关系啊!你看Object类里的getClass()是public的啊,你那样写没有任何问题!
* @return The {@code Class} object that represents the runtime
* class of this object.
返回的是运行时类的对象啊,所以它可以调用方法getName