gpt4 book ai didi

Java注解VS静态或全局变量

转载 作者:行者123 更新时间:2023-12-01 17:27:09 25 4
gpt4 key购买 nike

我正在回顾 Java 注释的工作原理,并意识到它是类的元数据。我有一些关于自定义注释的问题:

  1. 注释比静态或全局类变量更有用吗?

  2. 您能否举一个注释有用的真实示例?

最佳答案

1)我真的不认为“注释”、“静态变量”或“全局变量”之间有任何共同点 - 都是苹果、橙子和金橘。

2)“注释”的一个很好的例子可能是 JAXWS Web 服务:

3)这里有一个关于“注释”的很好的介绍:

* http://www.developer.com/java/other/article.php/3556176/An-Introduction-to-Java-Annotations.htm

It [annotation-based development] lets us avoid writing boilerplate code under many circumstances by enabling tools to generate it from annotations in the source code. This leads to a declarative programming style where the programmer says what should be done and tools emit the code to do it."

关于Java注解VS静态或全局变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14015715/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com