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.
- Single Line Comment
- Multi Line Comment
- Apex Single Line Comment
- Java Multi Line Comment
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() { System.debug(i); } }
The multi line comment is used to comment multiple lines of code in a single go.
Syntax:
/* This is multi line comments in Apex */
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() { System.debug(i); } }