Commenting in your java code
Java supports three types of comments, two of which are taken from C++. you can surround a comment of any length with the characters “/*’ and “*/”, like this:
/* This application prints out "Linux" */ public class abc { public static void main(string[] args) { system.out.println("Linux"); } }
The java compiler will ignore all the text between the /* and */ .
Java also supports a one-line comment, using a double slash(//). The java compiler will ignore everything on a line after the // , so you can create whole lines that ate comments or just add a comment to an individual line.
/* This application prints out "Linux" */ public class abc { //create the abc class public static void main(string[] args) { //print out the message with system.out.println("Linux"); } }
Java also supports a documentation comment, which starts with “/**” and ends with “*/”. This comment is designed to be used with the javadoc tool, which can create documentation for you nearly automatically.
Commenting your code can be invaluable in team environment where you share your code source file with others. it`s also handy if someone else is going to take over a project that you have been working on.