Java Comments
In this chapter you will learn:
- What are the three types of comment in Java
- How to use Java single line comment
- How to use Java multiline statement
Comments in Java
There are three types of comment supported in Java.
- Single-line,
- Multiline and
- Documentation comment.
Single-line comment
Java single line comment starts from //
and ends till the end of that line.
public class Main {
// This is a single line comment.
public static void main(String[] argv) {
}//from w w w.j a va 2 s. c o m
}
Multiline comment
Java multiline comment is between /*
and */
.
Everything from /*
through */
is ignored by the compiler.
public class Main {
/* This //from ww w . j av a2 s . c om
is
a
Multiline
comment.
*/
public static void main(String[] argv) {
}
}
Next chapter...
What you will learn in the next chapter:
- What is javadoc for
- Syntax for javadoc
- Example - Java documentation comment, Javadoc
- Javadoc tag list
- Example - More javadoc tags