MathBits.com
Return to Unit Menu |  Java Main Page | MathBits.com | Terms of Use  | Java Resource CD  

Examples of comments

There are 3 styles of comments:

/**documentation */ - documentation commenting.   
/* text*/ - is the format for block commenting.
// text - is the format for single line commenting.

Comment statements are ignored by the compiler.
Comments are simply messages to the reader of the code.


/************************************
*Project:  Demo for Comments
*Programmer:  Mr. Data
*Date:  June, 2003
*Program Name:  Comments.java
*************************************/ 

import java.io.*;
public class Comments
{
     public static void main (String[ ] args)
     {
            System.out.println("Hi");  //message to user
           
System.out.println("LabOneA");  //assignment
 
     }
}
/* if you want to write a detailed comment, and it wraps around the screen, use this block style of commenting. */

 

The CODE: Information about the code:
/************************************
*Project:  Demo for Comments
*Programmer:  Mr. Data
*Date:  June, 2003
*Program Name:  Comments.java
*************************************/ 
All programs should begin with a comment identifying the purpose of the program and the programmer.  For our course please use the style shown at the left.  
import java.io.*;
public class Comments
{
     public static void main (String[ ] args)
     {
       System.out.println("Hi");  //message to user
      
System.out.println("LabOneA");  //assignment
 
    }
}
Comments can also be placed within the body of a program to act as documentation.  These comments should be brief and to the point.
This body prints
Hi! on the screen and LabOneA on the screen.
/* if you want to write a detailed comment, and it wraps around the screen, use this block style of commenting. */ The block form of commenting is used to display lengthy comments that wrap around the screen.

                                                                    


Return to Unit Menu | Java Main Page | MathBits.com | Terms of Use  | Java Resource CD