Utilizor
Contact Us

Java Comments

Java Code Comments.

Examples

Single-line Comment

Comment on its own line.

public class Main {
  public static void main(String[] args) {
    // This is a comment
    System.out.println("Hello World");
  }
}

End of Line Comment

Comment at the end of a line of code.

public class Main {
  public static void main(String[] args) {
    System.out.println("Hello World"); // This is a comment
  }
}

Multi-line Comment

Comment spanning multiple lines.

public class Main {
  public static void main(String[] args) {
    /* The code below will print the words Hello World
    to the screen, and it is amazing */
    System.out.println("Hello World");
  }
}

Test Your Knowledge

Java Quiz

No quiz available for this topic yet.