Comments and whitespace are removed by the Java compiler, during tokenization of the source code.
Comments in Java are defined in three ways:
- /* comment */ - Used for multiple line comments. All the characters between /* and */ are ignored.
- // comment - Used for single line comments. All the characters after //, until the end of the line are ignored.
- /** comment / - Same as /* */, except that the comment can be used with the javadoc tool to create automatic documentation. javadoc is a Java automatic documentation tool i.e. it creates automatic documentation from source code.
Whitespace in Java can consist of spaces, tabs and linefeeds. All occurrences of whitespace and comments are removed by the Java compiler.