@符号在java中是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2971521/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 15:02:51  来源:igfitidea点击:

What does the @ sign means in java?

javaoopannotations

提问by henry

Below is the code snippet.

下面是代码片段。

@Intercepts({@Signature(
type= Executor.class,
method = "update",
args = {MappedStatement.class,Object.class})})
public class

Can someone explain to me what @ sign means in Java?

有人可以向我解释 @ 符号在 Java 中的含义吗?

采纳答案by Ryan Hayes

It's an Annotation.

这是一个Annotation

Annotations are a form of metadata. They provide data about a program that is not part of the program itself. Annotations have no direct effect on the operation of the code they annotate.

注释是元数据的一种形式。它们提供有关不属于程序本身的程序的数据。注释对其注释的代码的操作没有直接影响。

Annotations do affect the way programs are treated by tools and libraries, which can in turn affect the semantics of the running program. Annotations can be read from source files, class files, or reflectively at run time.

注释确实会影响工具和库处理程序的方式,这反过来又会影响正在运行的程序的语义。可以从源文件、类文件或在运行时反射地读取注释。

回答by Joel

It's an annotation.

这是一个注释。

Here's more information on it: http://www.alden-java-hosting.com/JAVA-tutorial/java/javaOO/annotations.html

这里有更多关于它的信息:http: //www.alden-java-hosting.com/JAVA-tutorial/java/javaOO/annotations.html

Here are Oracle's docs since it looks like the other link is down: http://docs.oracle.com/javase/tutorial/java/annotations/

这是 Oracle 的文档,因为它看起来像另一个链接已关闭:http: //docs.oracle.com/javase/tutorial/java/annotations/

回答by Madabitjer

Yeap. All the previous posters are correct, it's annotations and the links are correct.

是的。之前的所有海报都是正确的,注释和链接都是正确的。

For our C# buddies out there, I think it's akin to attributes.

对于我们的 C# 伙伴来说,我认为它类似于属性。

回答by Shashank T

Its is a Annotation and it serves very great purpose as metadata to inform JVM about methods or other things.

它是一个注解,它作为元数据有很大的作用,可以通知 JVM 方法或其他事情。