ACTS COMPUTER COLLEGE - INFANTA | by maria cristina b. nazareno
[IT ELECTIVE 1]
| Lesson 2
Program comments are non-executing statements that you add to a
program for the purpose of documentation. Programmers use comments to leave notes for themselves and for others who might read their programs in the future. At the very least, your Java class files should include comments indicating the author, the date, and the class name or function. The best practice dictates that you also include a brief comment to describe the purpose of each method you create within a class. There are three types of comments in Java: Line comments start with two forward slashes ( // ) and continue to the end of the current line. A line comment can appear on a line by itself or at the end (and to the right) of a line following executable code. Line comments do not require an ending symbol. Block comments start with a forward slash and an asterisk ( /* ) and end with an asterisk and a forward slash ( */ ). A block comment can appear on a line by itself, on a line before executable code, or on a line after executable code. Block comments also can extend across as many lines as needed. Javadoc comments are a special case of block comments. They begin with a forward slash and two asterisks ( /** ) and end with an asterisk and a forward slash ( */ ). You can use javadoc comments to generate documentation with a program named javadoc. Exercises: 1. Write a class that displays your first name on the screen. 2. Write a class that displays the following pattern on the screen: X XXX XXXXX XXXXXXX X
ACTS COMPUTER COLLEGE - INFANTA | by maria cristina b. nazareno