JAVA COMMENTS
Comments are used to add additional details in a program and it help a programmer to easily understand the code written by other programmers (mostly usable to understand the complex code).
In Java and other programming language comments are ignore by compiler means, its does not executed by the compiler.
Java comments are classified into the following two categories.
1. Single line comment.
2. Multi line comment.
SINGLE LINE COMMENTS
Single-line comments are start with two forward slashes (//).
Any text written after these two forward slashes (//) ignores by Java compiler, means it will not execute by the Java compiler.
This example uses a single-line comment in Java, before a line of the code:
// The below statement will print a message in output window.
System.out.println("Welcome in my first Java program");
JAVA MULTI-LINE COMMENTS
Multi-line comments start with /* and ends with */.
Any text between /* and */ will not execute by the Java compiler.
This example shows that, how to use the a multi-line comment in the Java programming code.
/* The code below will print the words Hello World
to the screen, and it is amazing */
System.out.println("Welcome in my first Java program");
Any text written after these two forward slashes (//) ignores by Java compiler, means it will not execute by the Java compiler.
This example uses a single-line comment in Java, before a line of the code:
// The below statement will print a message in output window.
System.out.println("Welcome in my first Java program");
JAVA MULTI-LINE COMMENTS
Multi-line comments start with /* and ends with */.
Any text between /* and */ will not execute by the Java compiler.
This example shows that, how to use the a multi-line comment in the Java programming code.
/* The code below will print the words Hello World
to the screen, and it is amazing */
System.out.println("Welcome in my first Java program");
0 Comments