java注解2

     由前一篇的代码,运行代码如下:public class StatementHelper {

	public static String getStatement(String actionName, Object obj) {
		return null;
	}
	
	public static Field[] getFileds(Object obj){
		Class<?> classType = obj.getClass();
		return classType.getDeclaredFields();
	}
	
	public static void main(String[] args){
		News news = new News("标题","内容",true);
		Field[] f = StatementHelper.getFileds(news);
		int len = f.length;
		System.out.println(len);
		for(int i = 0; i < len; i++)
			System.out.println(f[i]);
	}

}
//输出结果
//0
//根据上面的结果,我们可以看到只会输出当前类中的变量。

你可能感兴趣的:(java注解)