1. “String” instanceof Object
--- true
2. new String() instanceof String
--- true
3. new Object() instanceof String
--- false
4. 'A' instanceof Character
--- 编译错
5. null instanceof String
--- false
6. (String)null instanceof String
--- false
7. new Date() instanceof String
--- 编译错
8. new GenericClass<String> () isDateInstance("") 编译可通过
--- false
class GenericClass<T>{
boolean isDateInstance(T t){
return t instanceof Date;
}
}
--- true
2. new String() instanceof String
--- true
3. new Object() instanceof String
--- false
4. 'A' instanceof Character
--- 编译错
5. null instanceof String
--- false
6. (String)null instanceof String
--- false
7. new Date() instanceof String
--- 编译错
8. new GenericClass<String> () isDateInstance("") 编译可通过
--- false
class GenericClass<T>{
boolean isDateInstance(T t){
return t instanceof Date;
}
}