public interface IObject {
}
public class Foo implements IObject{
}
public class Test extends Foo{
}
public class MultiStateTest {
public static void main(String args[]){
test();
}
public static void test(){
IObject f=new Test();
if(f instanceof java.lang.Object)System.out.println("true");
if(f instanceof Foo)System.out.println("true");
if(f instanceof Test)System.out.println("true");
if(f instanceof IObject)System.out.println("true");
}
}
输出结果:
true
true
true
true