在Java注释中基本包括单行注释多行注释。
单行注释:使用“//”开头,在后面添加文字注释。
多行注释:使用“/”开头以“/”结尾。
文档注释:使用“/**”开头,以“*/”结束。也是多行注释。
编写注释的原因:用以说明某段代码的作用,便于程序员阅读,便于代码的后期维护和升级。
public class HelloWorld{
public static void main(String [] args){
System.out.println("HelloWorld");//单行注释。
}
}
多行注释:
/*
*This is a comment.
*Zhanghe
*/
public class HelloWorld{
public static void main(String [] args){
System.out.println("HelloWorld");//单行注释。
}
}
文档注释:
/**
*This is a comment.
*Zhanghe
*/
public class HelloWorld{
public static void main(String [] args){
System.out.println("HelloWorld");//单行注释。
}
}在这里插入代码片
使用JDK中javadoc命令生成文档。
根据路径打开文档windows+e,在c盘中找到打开。