• We just launched and are currently in beta. Join us as we build and grow the community.

Comments

ushowardlink

Traffic Strategist
U Rep
0
0
0
Rep
0
U Vouches
0
0
0
Vouches
0
Posts
144
Likes
42
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
Introduction:
Welcome to a tutorial on the use of comments within Java.

What are comments?

When are comments used?

What is the format for a comment?
To submit a comment within Java, there are two ways to do this, the first one is a simple, one line comment which begins with two forward slashes ("//"). The second way allows multiple comment lines in a row which start with an asterix ("*") and is initialised by "/**" and terminated with "*/". Examples below.

Examples:
Here is an example of both types of comment...

  1. //System.out.println("1 This line is a comment and so is not ran by Java.");
  2. System

    .out

    .println

    (

    "2 This line is not a comment and so is ran by Java."

    )

    ;

  3. /**
  4. * System.out.println("3 This line is a comment and so is not ran by Java.");
  5. * System.out.println("3.5 This line is a comment and so is not ran by Java.");
  6. */
  7. System

    .out

    .println

    (

    "4 This line is not a comment and so is ran by Java."

    )

    ;

2 This line is not a comment and so is ran by Java.
4 This line is not a comment and so is ran by Java.

As you can see, the three lines in the comment types are not ran by Java.

Finished!

Book traversal links for Comments

  • ‹ Arrays
  • Up
  • Date and Time ›

 

452,292

323,526

323,535

Top