67,513
社区成员
发帖
与我相关
我的任务
分享
if (VO.class.isInstance(args[0])) {
System.out.println("相同");
}
if (args[0] instanceof VO) {
System.out.println("相同");
}
public class App {
public static void main(String[] args) {
Inter vo = (Inter) Proxy.newProxyInstance(App.class.getClassLoader(), VO.class.getInterfaces(), new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (args[0].getClass() == VO.class) {
System.out.println("相同");
}
return null;
}
});
vo.getString(new VO());
}
}
interface Inter {
public void getString(VO v);
}
class VO implements Inter {
public void getString(VO v) {
System.out.println("--------------");
}
}