Java Cheat Sheet


  // Single-line comment
  // This is a single-line comment in Java. It starts with two slashes.
  
   /*
    * Multi-line comment
    * This type of comment spans multiple lines.
    * It starts with a slash and an asterisk and ends with an asterisk and a slash.
    */
  
  /**
   * Documentation comment
   * This is a documentation comment used for generating JavaDocs.
   * It provides descriptions for classes, methods, and fields.
   * @param args The command-line arguments
   */
  public class CommentsExample {
      public static void main(String[] args) {
          // This line prints a message to the console
          System.out.println("Hello, World!"); // Inline comment
      }
  }
  
© 2024 CheatsheetCoder, All Rights Reserved.