Course Content‎ > ‎Session 2‎ > ‎

Comments and Whitespace

Comments and whitespace are removed by the Java compiler, during tokenization of the source code. 

Comments

Comments in Java are defined in three ways: 

  1. /* comment */ -  Used for multiple line comments. All the characters between /* and */  are ignored. 
  2. // comment - Used for single line comments. All the characters after //, until the end of the line are ignored. 
  3. /** 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

Whitespace in Java can consist of spaces, tabs and linefeeds. All occurrences of whitespace and comments are removed by the Java compiler.
Comments