How to write multi-line comment in Java?

Java 8Object Oriented ProgrammingProgramming

Multi line comments in Java start with /* and end with */. You can comment multiple lines just by placing them between /* and */.

/* Hello this is the way
  to write multi line comments in Java */

Example

Following example demonstrates the usage of multiline comments in Java.

Live Demo

public class CommentsExample {
   /*
      Following is the main method here,
      We create a variable named num.
      And, print its value    
   * */
   public static void main(String args[]) {
      int num = 1;
      System.out.println("value if the variable num: "+num);
   }
}

Output

value if the variable num: 1
raja
Published on 05-Jan-2018 12:41:42
Advertisements