首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

第五十五道Java小疑点

2012-12-21 
第五十五道Java小问题import java.lang.annotation.ElementTypeimport java.lang.annotation.Retentioni

第五十五道Java小问题

import java.lang.annotation.ElementType;import java.lang.annotation.Retention;import java.lang.annotation.RetentionPolicy;import java.lang.annotation.Target;import java.lang.reflect.Method;@Target(ElementType.METHOD)@Retention(RetentionPolicy.RUNTIME)@interface TestAnnotation { public int id() default 5; public String description();}class Anno { @TestAnnotation(id = 6, description = "G") public void g() { } @TestAnnotation(id = 7, description = "I") protected void i() { } @TestAnnotation(id = 8, description = "F") void f() { } @TestAnnotation(id = 9, description = "H") private void h() { }}public class Test { public static void main(String[] args) {  Method[] methods = Anno.class.getMethods();  for (Method m : methods) {   TestAnnotation a = m.getAnnotation(TestAnnotation.class);   // System.out.print(m.getName());   if (a != null)    System.out.print(a.id());  } }}

?

?

请问以上程序的输出是:

热点排行