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.