Tuesday, October 16, 2012

Java Comments


Comments

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. (Shown in the above program)
Documentation style comments begin with /** and terminate with */ that spans multiple lines.

/** This class is a Hello World Program used to introduce
the Java Language*/
public class HelloWorld {
public static void main(String[] args) {
System.out.println(“Hello World”); //Prints output to console

}
}




They are generally created using the automatic documentation generation tool, such as javadoc. (Shown in the above program)
name of this compiled file is comprised of the name of the class with .class as an extension.

No comments:

Post a Comment