正在加载图片...
public void show Kind( Class classobjt if(classObj. isInterfaceo) System. out. printIn("It is an interface type); else if(classobj. isArrayo) System. out. println(“ It is an array type”); else if(class Obj. isPrimitiveO) System. out. printIng(“ It is a primitive type”) else System. out. printIn(“ It is a class type”); show Kind(String class); show Kind (serializable class); show Kind(bytel class); show Kind(int class); It is a class type It is an interface type It is an array type It is a primitive typeMethods for Type Kind • 该类提供了以下方法用于判断Class对象的 类型: public boolean isInterface() public boolean isArray() public boolean isPrimitive() public void showKind(Class classObj){ if(classObj.isInterface()) System.out.println(“It is an interface type”); else if(classObj.isArray()) System.out.println(“It is an array type”); else if(classObj.isPrimitive()) System.out.println(“It is a primitive type”); else System.out.println(“It is a class type”); } showKind(String.class); showKind(Serializable.class); showKind(byte[].class); showKind(int.class); It is a class type It is an interface type It is an array type It is a primitive type
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有