Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在类中的注释内编写注释?_Java_Annotations - Fatal编程技术网

Java 如何在类中的注释内编写注释?

Java 如何在类中的注释内编写注释?,java,annotations,Java,Annotations,为了好玩,我试图编写一个使用注释的类,其中包含另一个注释,但我不知道如何编写 我的代码 第一注释 第二个注释,包含第一个注释 带注释的类 我必须将字符串编译代码作为类中FirstAnnotation的实际值的参考放入行中吗?您的类应该是: @SecondAnnotation( version = 1, inside = @FirstAnnotation( author = "alessandro" ) ) public class General

为了好玩,我试图编写一个使用注释的类,其中包含另一个注释,但我不知道如何编写

我的代码 第一注释 第二个注释,包含第一个注释 带注释的类 我必须将字符串编译代码作为类中FirstAnnotation的实际值的参考放入行中吗?

您的类应该是:

@SecondAnnotation(
    version = 1,
    inside = @FirstAnnotation(
          author = "alessandro"
    )   
)
public class GeneralClass {

    /*
     * a generic method
     */ 
    public void method() {
        System.out.println("method");
    }

}
你的班级应该是:

@SecondAnnotation(
    version = 1,
    inside = @FirstAnnotation(
          author = "alessandro"
    )   
)
public class GeneralClass {

    /*
     * a generic method
     */ 
    public void method() {
        System.out.println("method");
    }

}
@FirstAnnotation(author=“something”)@FirstAnnotation(author=“something”)
@FirstAnnotation(
    author = "alessandro"
)
@SecondAnnotation(
    version = 1,
    inside = /*Compilation code: what code? FirstAnnotation, this??*/   
)
public class GeneralClass {

    /*
     * a generic method
     */ 
    public void method() {
        System.out.println("method");
    }

}
@SecondAnnotation(
    version = 1,
    inside = @FirstAnnotation(
          author = "alessandro"
    )   
)
public class GeneralClass {

    /*
     * a generic method
     */ 
    public void method() {
        System.out.println("method");
    }

}