Another magical use of Java annotations

Source: Internet
Author: User

Every Java programmer will use the comments when writing the program, this blog is not about how to define the comments, but rather a description of the magic of the comment notation.

1 /**2 * This is a test class3  */4  Public classTest {5     /**6 * Entrance to the program7      */8      Public Static voidMain (string[] args) {9         NewTest ();Ten     } One}

Here are two common multiline annotations, in the idea environment, select the method or class name, press and hold Ctrl+q (Ctrl and then move the mouse over the target) to see the comments for the corresponding target:

This allows you to see the annotation information for the corresponding target ( class or method ), but this is just a common comment, and the Magic Note is as follows:

Effect change: Font changed to Red, added an underscore, suspected link effect, font bold.

Looks like a link, a great feeling, click to see:

Into Baidu? What the hell.

.

See here, a lot of people may have guessed, yes, that's what you think, let's take a look at the comments after the change:

1 /**2 * <a href= 'http://www.baidu.com' style= ' color:red;font-weight:900: ' > This is a test class </a>3  */4  Public classTest {5     /**6 * Entrance to the program7      */8      Public Static voidMain (string[] args) {9         NewTest ();Ten     } One}

See, it seems a little familiar, html+css?

Yes, the Magic feature in Java annotations is to support some of the tags in Html+css, with the above code we have changed the font to a hyperlink, and the font is set to red, the word weight 900.

Since some of the HTML+CSS tags are supported in Java annotations, you can use this approach to emphasize when writing notes that are particularly noteworthy.

Another magical use of Java annotations

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.