×
☰ See All Chapters

How to comment java code

Comments are generally ignored by compilers and interpreters. Comments are used to add notes, information, and programmer-readable explanation. There are three techniques for adding comments to your Java code, each of which has their own particular usage. Below are the three techniques to comment the java code:

  1. // Use the two forward slashes to comment out text that appears after the forward slashes but on the same line. This is used to add single line comments. 

  2. /* and */ Use the /* to turn on comments, and all text will be commented until a */ is reached. This is useful for commenting out multiple lines of code. This is used to add multiline comments. 

  3. /** and */ A special type of comment used specifically with the javadoc tool for generating HTML files that contain your comments. This feature of Java is widely used, and it is expected that these HTML pages accompany any Java code that is distributed among developers. 

how-to-comment-java-code-0
 

All Chapters
Author