Java 注释的类型
@H_502_0@Java 中的注释分为三种类型。单行注释
@H_502_0@单行注释以 // 开始,到行尾结束。示例 1
public class SingleLineComment { public static void main(String[] args) { // To print output in the console System.out.println("Welcome to Tutorials Point"); } }
输出
Welcome to Tutorials Point
多行注释
@H_502_0@多行注释以 /* 开头,以 */ 结尾,跨多行。示例 2
public class MultiLineComment { public static void main(String[] args) { /* To print the output as Welcome to Tutorials Point in the console. */ System.out.println("Welcome to Tutorials Point"); } }
输出
Welcome to Tutorials Point
文档注释
@H_502_0@文档样式注释以 /** 开头,以 */ 结尾,并且跨多行。文档注释必须紧接在类、接口、方法或字段定义之前。示例 3
/** This is a documentation comment. This class is written to show the use of documentation comment in Java. This program displays the text "Welcome to Tutorials Point" in the console. */ public class DocumentationComment { public static void main(String args[]) { System.out.println("Welcome to Tutorials Point"); } }
输出
Welcome to Tutorials Point@H_502_0@以上就是如何在Java代码中添加不同的注释?的详细内容,更多请关注编程之家其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。