how can comments be inserted in a java program
Answers
Answered by
9
hey! friend here is your Answer
public class CommentsDemo1{ public static void main(String args[]) { //I am a single line comment System.out.println("Hi World"); }}
The program given below has a single line comment in it
public class CommentsDemo1{ public static void main(String args[]) { //I am a single line comment System.out.println("Hi World"); }}
Nikhitabisht:
hope i helped u
Answered by
9
Comments are parts of the program essential for explaining the code and it does not get included during the compilation .
There are 3 types of comments .
⏩ Single line comments .
⏩ Multi line comments .
⏩ Documentation comments .
We can insert a single line comment by two forward slashes .
Example :
int x=5 ; // x is a variable .
We can insert a multi line comment by putting a forward slash and then an asterisk and ends with the same .
Example :
/* I am
multiple
line comment */
We can insert a documentation comment by putting a forward slash and then two asterisks but ends with the same as that of multi line comments.
Example :
/** Documentary */
Similar questions