Java 注释

Java Annotations(Java 注释)
本文介绍了Java 注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

Java 中注解的目的是什么?我有一个模糊的想法,认为它们介于注释和实际代码之间.它们在运行时会影响程序吗?

What is the purpose of annotations in Java? I have this fuzzy idea of them as somewhere in between a comment and actual code. Do they affect the program at run time?

它们的典型用法是什么?

What are their typical usages?

它们是 Java 独有的吗?有 C++ 等价物吗?

Are they unique to Java? Is there a C++ equivalent?

推荐答案

注解主要用于检查其他代码的代码.它们通常用于在运行时修改(即装饰或包装)现有类以改变它们的行为.JUnit 和 Hibernate 使用注解来最大限度地减少您自己编写以使用框架所需的代码量.

Annotations are primarily used by code that is inspecting other code. They are often used for modifying (i.e. decorating or wrapping) existing classes at run-time to change their behavior. Frameworks such as JUnit and Hibernate use annotations to minimize the amount of code you need to write yourself to use the frameworks.

Oracle 对这个概念及其Java 中的含义 在他们的网站上.

Oracle has a good explanation of the concept and its meaning in Java on their site.

这篇关于Java 注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

quot;Char cannot be dereferencedquot; error(“Char 不能被取消引用错误)
Java Switch Statement - Is quot;orquot;/quot;andquot; possible?(Java Switch 语句 - 是“或/“和可能的?)
Java Replace Character At Specific Position Of String?(Java替换字符串特定位置的字符?)
What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作数的三元表达式的类型是什么?)
Read a text file and store every single character occurrence(读取文本文件并存储出现的每个字符)
Why do I need to explicitly cast char primitives on byte and short?(为什么我需要在 byte 和 short 上显式转换 char 原语?)