Comments are descriptions that are added to a program to make code easier to understand. The compiler ignores comments and hence its only for documentation of the program.
Java supports three comment styles.
- Block style comments begin with /* and terminate with */ that spans multiple lines.
- Line style comments begin with // and terminate at the end of the line.
- Documentation style comments begin with /** and terminate with */ that spans multiple lines. They are generally created using the automatic documentation generation tool, such as javadoc.
For Example:
class HelloWorld
{
public static void main (String args[]) //main method definition
{
System.out.println("Hello World!"); /* System.outpritln is used for
printing */
}
}
0 comments:
Post a Comment