Salesforce Menu

Apex Comments

The Apex comments are the statements that are not executed by the Apex compiler. The comments can be used to provide additional information about the variable, method, class or any other statement.

Types of Apex Comments

There are two types of comments in Apex.

  1. Single Line Comment
  2. Multi Line Comment
  1. Apex Single Line Comment
  2. The single line comment is used to comment one line at a time.

    Syntax of single line comment:

    // this is single line comment in code

    Example of Single line comment:

    Public class SingleLineCommentDemo {
    Integer i = 100; // initialized i variable with 100 value
    public void getValue() {
  3. Java Multi Line Comment
  4. The multi line comment is used to comment multiple lines of code in a single go.


    multi line  

    Example of Multi line comment:

    Public class MultiLineCommentDemo {
    initialized i variable with 100 value
    as well as we are showing its value too using debug statement
    Integer i = 100; 
    public void getValue() {
Subscribe Now