topLogoIntro
Return to Unit Menu |  JavaBitsNotebook.com | MathBits.com | Terms of Use  | JavaMathBits.com

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:  DemoCom
* @author  Johnathan Data
*Date:  June 4
*Program Name:  Comments.java
************************************/ 

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:  DemoCom
* @author Johnathan Data
*Date:  June 4
*Program Name:  Comments.java
*************************************/ 
All programs should begin with a comment identifying the purpose of the program and the programmer.  For class, you may be asked to start your programs with a comment similar to the one shown.  
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 down onto another line, use this block style of commenting. */ The block form of commenting is used to display lengthy comments that wrap around the screen.

The output from this program will be:

lab3

divider
Return to Unit Menu |  JavaBitsNotebook.com | MathBits.com | Terms of Use  | JavaMathBits.com

Notice: These materials are free for your on-line use at this site, but are not free for the taking.
Please do not copy these materials or re-post them to the Internet, as it is copyright infringement.
If you wish hard-copies of these materials, refer to our subscription area, JavaMathBits.com.
Help us keep these resources free. Thank you.