class A
{
public static void main(String args[])
{
Boolean b;
String str = "foo";
b = ( str instanceof String ); // true
b = ( str instanceof Object ); // also true
b = ( str instanceof java.util.Date ); // false, not a Date or subclass }
}
{
public static void main(String args[])
{
Boolean b;
String str = "foo";
b = ( str instanceof String ); // true
b = ( str instanceof Object ); // also true
b = ( str instanceof java.util.Date ); // false, not a Date or subclass }
}
Object对象 instanceof 具体Class
父Class对象 instanceof 子Class
子Class对象 instanceof 父Class但是不能进行确定没有父子关系之间的Class判断