java comments-
- comments illustrate java code and it makes the code more smooth and lucid
- lines of code inside the comments are isolated by the compiler in time of the compiling process......
- Single-line Comments
- Single-line comments start with two forward slashes (//).
Anything between // and the end of the line is ignored by Java compiler (will not be executed).
This example uses a single-line comment before a line of code:
Example
1.public class Best{
public static void main(String[] args) {
// This is a comment
System.out.println("Welcome to techy sowmii");
}
}
output: Welcome to techy sowmii
comments are not executed by compiler
2.public class Best{
public static void main(String[] args) {
// This is a comment
System.out.println("Welcome to techy sowmii"); // This is a comment
}
}
output: Welcome to techy sowmii
you can use java comments all over between the lines of code
Java Multi-line Comments
- Multi-line comments start with /* and ends with */.
- Anything between /* and */ will be ignored by Java compiler in time of compiling and execution process
- Example
public class Best{
/* The code below will print the words Hello World
to the screen, and it is incredible*/
public static void main(String[] args) {
System.out.println("Welcome to techy sowmii");
}
}
Normally, we use // for short comments
/* */ for longer comments.
Related articles
A simple pillow talk between java and java user!!!!!!!!........
write java code in a simple text editor
Java Declare Multiple Variables
No comments:
Post a Comment
Did you find this article helpful?
😁 😀