有麻烦的方法的参数标注,下面是一个简单的测试演示,对错误的指示将受到欢迎:爪哇 - 参数标注
// Annotation
public @interface At {}
// Class
public class AnnoTest {
public void myTest(@At String myVar1, String myVar2){}
}
// Test
public class App {
public static void main(String[] args) {
Class myClass = AnnoTest.class;
Method method = myClass.getMethods()[0];
Annotation[][] parameterAnnotations = method.getParameterAnnotations();
// Should output 1 instead of 0
System.out.println(parameterAnnotations[0].length);
}
}
你面对什么样的错误? – Vihar