Home / Programs / Single Line Comment in java
🚀 Programming Example

Single Line Comment in java

👁 4,990 Views
💻 Practical Program
📘 Step Learning
In this section you will learn about Single Line Comment in java programming language.

📌 Information & Algorithm

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.

Types of Java Comments

There are 3 types of comments in java.

  1. Single Line Comment
  2. Multi Line Comment
  3. Documentation Comment

Java Single Line Comment

The single line comment is used to comment only one line.

Syntax:

 //This is single line comment  

💻 Program Code

 public class SingleLineComment {
public static void main(String[] args) {
    int i=10;//it is comment it says Here, i is a variable
    System.out.println(i);
   }
}

                        

🖥 Program Output

10
Press any key to continue . . .
                            

📘 Explanation

📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.