getclass和instanceof

138 阅读1分钟

首先假设有变量Integer i;

getclass是获得对象的类,例如integer.getClass();

i instanceof Integer是判断 i 是否是 Integer类型的,或者是Integer的子类