Multi Line Comment in java
In this section we will discuss about multi Line Comment in java programming language.
In this section we will discuss about multi Line Comment in java programming language.
The java comments are statements that are not executed by the compiler and interpreter. The comments can be used to provide information or explanation about the variable, method, class or any statement. It can also be used to hide program code for specific time.
There are 3 types of comments in java.
The multi line comment is used to comment multiple lines of code.
/*
This
is
multi line
comment
*/
public class MultiLineComment {
public static void main(String[] args) {
/* it's a multiline comment, we are going
declare and print variable in java. */
int j=10;
System.out.println(j);
}
}
10
Press any key to continue . . .
public class CommentExample2 {
public static void main(String[] args) {
/* Let's declare and
print variable in java. */
int i=10;
System.out.println(i);
}
}
First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.
After understanding this example, try to rewrite the same program without looking at the code. Then change some values or logic and run it again. This helps improve confidence and keeps learners engaged on the page for longer.