它在注解中似乎有特殊意义——它允许你在实例化注解时跳过参数名。
@Foo(bar = "abc") // a normal instantiation of an annotation
@Foo("abc") // if bar were renamed 'value'
这是在哪里记录的? value
是不是关键字? See also .
最佳答案
它不是常规关键字,因为它未在 section 3.9 of the JLS 中列出.特别是,据我所知,您可以在任何地方将其用作标识符。
在 section 9.7 中指定了默认使用 value
作为注释值:
The third form of annotation, single-element annotation, is a shorthand designed for use with single-element annotation types:
SingleElementAnnotation: @ TypeName ( ElementValue )
It is shorthand for the normal annotation:
@TypeName ( value = ElementValue )
关于java - 'value' 是java关键字吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6571827/