COMMENTS
The comments are not executed by compiler and interpreter. The comments can be used for providing information and explanation about the content in the program(like: variable,constant,method, class etc) and any statement.
It can also be used to hide program code for specific time.
Types of java comments
There are 3 types of java comments.
- Single line comment
- Multi line comment
The single line comment used for only single line.
Syntax:
// This is single line comment
Example:
Public class Singlelinecomment{
public static void main(Strings args[]){
int i=10; //here, i is a variable
System.out.println(i);
}
}
Output: 10
Java multi line comment
The multi line comment is used for multi lines of code.
Syntax:
/*
This is
multi line
comment
*/
Example:
public class Multilinecomment{
public static void main(String[] args){
/* Declare and
print variable
in java
*/
int i=10;
System.out.println(i);
}
}
Output: 10
No comments:
Post a Comment