Small Java Programs
15. Comments
Answer:
No. Everything is so confused, a slight mistake is easily overlooked.
Students sometimes try to save typing by not indenting sensibly. Often, this results in hours of debugging.
Comments
Here is the completed program. Be sure that you put the quote marks where they belong. If you forget just one of them, the compiler will become confused and will not translate your program!
|
A comment is a note written to a human reader of a program. A comment starts with the two characters //
(slash slash). Those characters and everything that follows them on that one line are ignored by the java compiler.
The program compiles and runs exactly the same as before. Most program editors (such as Notepad++) are smart enough to recognize comments and will display them in color. Of course, the text file contains only the characters you have entered. The colors are how the editor displays them. (Unlike a word processor, where the colors of text are actually encoded in the file.)
Question 15:
Are comments translated into bytecode by the compiler?