java注释库还是语言功能?
Java注释应该被视为一种语言或库特性吗。很明显,@是指一种特定的注释,而不是一种特定的注释
显然,只有第三方库支持的注释(例如Hibernate注释)显然不是Java语言的一部分,但对于内置注释,我不太确定
如果这被认为过于散漫,请随意转向程序员。斯塔克交换。com
你可以在下面搜索框中键入要查询的问题!
Java注释应该被视为一种语言或库特性吗。很明显,@是指一种特定的注释,而不是一种特定的注释
显然,只有第三方库支持的注释(例如Hibernate注释)显然不是Java语言的一部分,但对于内置注释,我不太确定
如果这被认为过于散漫,请随意转向程序员。斯塔克交换。com
# 1 楼答案
注释(在Java中)用于向代码中添加元数据。注释是编写可读和可维护代码的方法。因此,无论注释是Java注释还是任何其他第三方,都要使用注释来编写好的代码
例如,想让EJB变成无状态,现在只需要添加@stateless注释
# 2 楼答案
像
@Deprecated
和@Override
这样的注释是库功能,语言工具使用它们来强制和/或描述代码行为。肯定是图书馆的特色# 3 楼答案
我是这样想的:
JLS描述了Java编程语言。正如您清楚地理解的,注释的概念是一种语言特性。另一方面,JLS没有描述大量标准Java库功能,比如Collections API
从JLS §9.6.1, Predefined Annotation Types
按照这些思路,我认为Java注释是一种库特性