Another magical method of JAVA annotation is java annotation.

Source: Internet
Author: User

Another magical method of JAVA annotation is java annotation.

Every JAVA programmer must use comments when writing a program. This blog does not refer to how to define comments, but to a magic way of writing comments.

1/** 2 * this is a Test class 3 */4 public class Test {5/** 6 * program entry 7 */8 public static void main (String [] args) {9 new Test (); 10} 11}

The preceding two comments are common multiline comments. In the IDEA environment, select the method or Class Name and press Ctrl + Q (in the Eclipse development environment, press Ctrl and move the cursor to the target) you can view the comments of the target ,:

In this way, you can see the comment information of the corresponding target (class or method), but this is just a common comment. The magic comment is as follows:

Effect change: the font turns red and an underline is added. It is suspected that the link effect is displayed. The font is bold.

It looks like a link. It feels great. Click to see it:

Entering Baidu? What the hell.

.

Many people may have guessed it here. That's right. That's what you think. Let's take a look at the modified comments:

1/** 2 * <a href = 'HTTP: // www.baidu.com 'style = 'color: red; font-weight: 900: '> This is a Test class </a> 3 */4 public class Test {5/** 6 * program entry 7 */8 public static void main (String [] args) {9 new Test (); 10} 11}

No, it seems a little familiar, HTML + CSS?

Yes, the magic function in JAVA comments is to support some labels in HTML + CSS. Through the above Code, we changed the font to a hyperlink and set the font to red, with a word weight of 900.

Since JAVA annotations support part of HTML + CSS tags, this method can be used to emphasize some notes that require special attention.

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.