+91 81900 98289

Java Comments

A comment is text for the next person who reads the file, including you next month. // comments out the rest of one line. /* and */ comment out a block.

Comments are removed before the class runs, so they cannot change the output. Do not comment out code to "save it for later" in a file you compile for class. Delete the dead lines or move them out.

Example

The comment is skipped. Only the string B2 is stored and printed.

public class Notes { public static void main(String[] args) { // Room code for the evening batch. String room = "B2"; System.out.println(room); } }
A comment that repeats the next line, such as // set room, does not help. Say why the value exists when the name alone is not enough.