标签:arraylist img java throwable span exce row err array
import java.util.List; import java.util.ArrayList; import java.lang.reflect.Method; import java.lang.reflect.Field; class S { private String name; private int age; public void setName(String name) { this.name = name; } public String getName() { return this.name; } } public class RefTest { public static void main(String[] args) { try { Class cls = Class.forName("S"); boolean b1 = cls.isInstance(new Integer(37)); System.out.println(b1); boolean b2 = cls.isInstance(new S()); System.out.println(b2); } catch (Throwable e) { System.err.println(e); } try { Class cls = Class.forName("S"); getProperty(cls); } catch (Throwable e) { System.err.println(e); } try { Class cls = Class.forName("S"); getMethods(cls); } catch (Throwable e) { System.err.println(e); } } public static Field[] getProperty(Class ownerClass) throws Exception { Field[] fields = ownerClass.getDeclaredFields(); for (int i=0; i<fields.length; i++) { System.out.println("Property: " + fields[i]); } return fields; } public static Method[] getMethods(Class ownerClass) throws Exception { Method[] methods = ownerClass.getDeclaredMethods(); for (int i=0; i<methods.length; i++) { System.out.println("Method: " + methods[i]); } return methods; } }
标签:arraylist img java throwable span exce row err array
原文地址:http://www.cnblogs.com/aguncn/p/6726075.html