Java Tutorial-Java Comments

Java Comments

Comments in Java are helpful to explain Java code and make it more readable.

Single-line comments start with two slashes ( // ). Any text between // and end of the line is ignored by the Java compiler.

Example:

//This is a comment.
System.out.println("Hello World");

Multi-line comments starts with /* and ends with */. Any text between /* and */ will be ignored by the compiler.

/* The code will print the String
* Hello World to the screen*/
System.out.println("Hello World");