How to Use Single-line Comment in Java


In this example, we will learn you how to use single-line comment at the end of a line of code in Java.

Source Code

package com.beginner.examples;

public class LineComment {
  public static void main(String[] args) {
    System.out.println("OK"); // single-line comment
  }
}

Output:

OK
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

How to Use Single-line Comment in Java


In this example, we will learn you how to use single-line comment before a line of code in Java.

Source Code

package com.beginner.examples;

public class CommentLine {
  public static void main(String[] args) {
    // single-line comment
    System.out.println("OK");
  }
}

Output:

OK
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments