Java的注释
Java的注释(注释语句不会在程序中执⾏)有三种⽅式:
1、单⾏注释。每⾏的代码前⾯标记//,表⽰从//开始到⾏结尾是注释语句。
1 package day01;2
3 public class Test01 {
4 public static void main(String[] args) {
5 System.out.println(\"we are chinese!\");//打印内容:“we are chinese!”6 }7 }
执⾏结果:
2、多⾏注释。使⽤/*……*/的格式进⾏标识
1 package day01; 2
3 public class Test01 {
4 public static void main(String[] args) {
5 System.out.println(\"we are chinese!\");//打印内容:“we are chinese!” 6 System.out.println(args); 7 /* System.out.println(args); 8 System.out.println(args);*/ 9 }10 }
执⾏结果:
3、⾃动⽣成⽂档注释
例如:设置—》editor—》file and code Templates,在files选项卡找到class⽂件,添加如下注释内容(新建java⽂件的时候都会⾃动加上这个注释信息,格式是/**开始,*/结束):
1 /** coding: utf-8
2 *@Time : ${DATE} ${TIME}3 *@Author : eleanor
4 *@Email : xx@163.com5 *@File : ${NAME}.java
6 *@Software: ${PRODUCT_NAME}7 */
执⾏结果:
注意:Java中/* */不能嵌套。如果代码本⾝有⼀个*/,就不能使⽤/*和*/注释起来。