Home Segments Top Top Previous Next

77: Mainline

You can include comments in Java programs in two ways. First, whenever the Java compiler encounters two adjacent forward slashes, //, anywhere in a line, the Java compiler ignores both slashes and the remainder of the line on which the slashes appear:

// Short comment 

Second, whenever Java encounters a slash followed immediately by an asterisk, /*, Java ignores both of those characters and all other characters up to and including the next asterisk followed immediately by a slash, */.

/* 
Long comment 
that just goes on 
and on 
*/ 

If you wish to test how a program works when you remove certain lines of source code, you can hide those lines in a comment, instead of deleting them.