如果在annotations中只有唯一一个成员,则该成员应命名为value:
/** * Associates a copyright notice with the annotated API element. */ public @interface Copyright { String value(); }
更为方便的是对于具有唯一成员且成员名为value的annotation(如上文),在其使用时可以忽略掉成员名和赋值号(=):
@Copyright("2002 Yoyodyne Propulsion Systems") public class OscillationOverthruster { ... }