How to Write Comments in Java
A comment in a Java program is one or more lines of text. A comment may be single line, multi-line or Javadoc. To practice writing each type of comment, follow these four steps.
- Open your text editor and create a new file. Type in the following Java statements. Observe the three types of comments and the examples of each type.
- Save your file as CommentsInJava.java.
- Open a command prompt and navigate to the directory containing your new Java program. Then type in the command to compile your program and hit Enter.
- Now you will run your Java program. Type in the command to run the Java runtime launcher and hit Enter. Notice the output from the block of code you wrote in the Java class.
Author: Stephen Withrow