Java FAQ _03 Basic Syntax (020) _ Annotations, comments What is the difference

Source: Internet
Author: User

Java Comment Annotations x comment Note Difference x Comment Note Confusion Xjava comment Note Difference x note differs from comment x
Click to enter _ more _java thousand ask

1. What is the difference between annotations and annotations?

See the comments here: what is the comment
See the annotations here: what are the annotations

Annotations and comments Many people confuse, and the application scenarios and specific uses are completely different, specifically as follows:

  1. Different uses
    Annotations tell the JVM about the additional information (meta information) of these elements by labeling elements such as packages, classes, fields, methods, local variables, method parameters, and so on.
    Annotations are used to tell developers the logic, description, features, etc. of this code, and can be freely played without restrictions.

  2. Specific use of different
    Annotations use @ To label the elements of the response, with strict restrictions on location, syntax, content, and, if there are any errors, an exception during compilation.
    Comments are very casual and can be filled with any content in the comments, without any restrictions, or even writing HTML.

  3. The compilation process is different
    Annotations can be configured to let the JVM read it in the run, and to do the corresponding operation, usually by reflection to get the annotations we have annotated for an element.
    Comments are completely ignored by the compiler and are provided entirely for the developer to use as a reference.

  4. Different in importance
    Annotations are becoming more important at this point, since he can describe and explain almost all the elements, and in most frameworks it is very much like using annotations to aid configuration.
    Annotations are becoming more and more sophisticated in code specifications today, and a good piece of code, even without any annotations, can make developers at a glance, and the sound of code 0 annotations is getting louder, and its only function is to generate Javadoc.

Java FAQ _03 Basic Syntax (020) _ Annotations, comments What is the difference

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.