Java注解 [英] Java Annotations
问题描述
什么是Java注释的目的是什么?我有他们的这一模糊的想法在注释和实际code之间的某处。难道他们所影响的程序在运行时?
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?
推荐答案
注解主要由code是检查其他code。它们经常用于修改(即,装饰或包裹)现有类在运行时改变其行为。框架如的JUnit 和休眠使用注解c您需要编写自己使用的框架,以尽量减少$ C $的金额。
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.
甲骨文拥有概念的一个很好的解释和它在Java中的意义一>在其网站上。
Oracle has a good explanation of the concept and its meaning in Java on their site.
这篇关于Java注解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!