本帖最后由 刘源 于 2012-8-14 20:21 编辑
“问题已经解决”。
@interface ItCastAnnotation {
}
@ItCastAnnotation
public class AnnotationTest {
public static void main(String[] args) throws Exception{
if(AnnotationTest.class.isAnnotationPresent(ItCastAnnotation.class))
ItCastAnnotation annotation = (ItCastAnnotation)AnnotationTest.class.getAnnotation(ItCastAnnotation.class);
}
}
错误提示:
Multiple markers at this line
- ItCastAnnotation cannot be resolved to a variable
- Syntax error, insert "AssignmentOperator Expression" to complete
Assignment
- Syntax error, insert ";" to complete Statement
- annotation cannot be resolved to a variable
什么意思啊。真看不懂了
我该成这样就没问题了,感觉和上面的没什么变化啊,上面那个哪里不对。
@interface ItCastAnnotation {
}
@ItCastAnnotation
public class AnnotationTest {
public static void main(String[] args) throws Exception{
ItCastAnnotation annotation =null;
if(AnnotationTest.class.isAnnotationPresent(ItCastAnnotation.class))
annotation = (ItCastAnnotation)AnnotationTest.class.getAnnotation(ItCastAnnotation.class);
}
}
|
|