In Java, we can annotate members like this:
@Annotation
private Type member;
My question is, can we provide different annotations for members of the same type declared in the same statement? Something like…
private Type @Annotation1 member1, @Annotation2 member2;
Annotations are basically modifiers, so no. You can not intermix different annotations in a multi-declaration statement anymore than you could intermix
private,public,static,volatileor any of the other Java modifiers.If you try it out in an IDE of your choice you will be able to verify this yourself of course.