Comments in Java: English & Tanglish Version✨📟

 Comments in Java✨📋

                                      ✨ENGLISH VERSION✨

Introduction:

Comments are an important part of Java programming. They are used to explain the code and make programs easier to understand.

Comments are ignored by the Java compiler, so they do not affect program execution.

In Java, there are three types of comments.

1. Types of Comments in Java:

Java supports three types of comments:

  1. Single-line Comments
  2. Multi-line Comments
  3. Documentation Comments

2. Single-line Comments:

Single-line comments are used to write explanations in a single line.

They start with two forward slashes (//).

Example:

public class SingleComment {
    public static void main(String[] args) {

        // Display a welcome message
        System.out.println("Welcome to Java");

    }
}

Output:

Welcome to Java

3. Multi-line Comments:

Multi-line comments are used to write explanations in more than one line.

They start with /* and end with */.

Example:

public class MultiComment {
    public static void main(String[] args) {

        /*
         This program displays
         a welcome message
        */

        System.out.println("Hello Java");

    }
}

Output:

Hello Java

4. Documentation Comments:

Documentation comments are used to describe classes, methods, and other program elements.

They start with /** and end with */.

These comments can be used by the Javadoc tool to generate documentation.

Example:

/**
 * This is a simple Java program.
 * It displays a welcome message.
 */
public class DocComment {
    public static void main(String[] args) {

        System.out.println("Welcome");

    }
}

Output:

Welcome

5. Advantages of Comments in Java:

  • Comments make the code easier to understand.
  • They help explain the purpose of the program.
  • They improve code readability.
  • They make program maintenance easier.
  • They help developers understand code written by others.

6. Important Points to Remember:

  • Comments are ignored by the Java compiler.
  • Single-line comments use //.
  • Multi-line comments use /* */.
  • Documentation comments use /** */.
  • Comments do not affect program execution.

Conclusion:

Comments play an important role in writing clear and understandable Java programs.

By using comments properly, programmers can make their code easier to read, understand, and maintain.


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

                                        ✨TANGLISH VERSION✨

Introduction:

Java programming-la Comments romba important role play pannudhu.

Comments use panni namma code pathi explanation write pannalam. Idhu program-ah easy-ah understand panna help pannum.

Java compiler comments-ah execute pannaadhu. So, comments program execution-ah affect pannaadhu.

Java-la three types of comments irukku.

1. Types of Comments in Java:

Java-la three types of comments use pannuvanga:

  1. Single-line Comments
  2. Multi-line Comments
  3. Documentation Comments

2. Single-line Comments:

Single-line comments-na oru single line-la explanation write panradhu.

Idhu two forward slashes (//) use panni start aagum.

Example:

public class SingleComment {
    public static void main(String[] args) {

        // Display a welcome message
        System.out.println("Welcome to Java");

    }
}

Output:

Welcome to Java

3. Multi-line Comments:

Multi-line comments-na multiple lines-la explanation write panradhu.

Idhu /* use panni start aagum. */ use panni end pannanum.

Example:

public class MultiComment {
    public static void main(String[] args) {

        /*
         This program displays
         a welcome message
        */

        System.out.println("Hello Java");

    }
}

Output:

Hello Java

4. Documentation Comments:

Documentation comments-na class, methods and program elements pathi detailed explanation write panna use panradhu.

Idhu /** use panni start aagum. */ use panni end pannanum.

Indha comments-ah Javadoc tool use panni documentation generate panna mudiyum.

Example:

/**
 * This is a simple Java program.
 * It displays a welcome message.
 */
public class DocComment {
    public static void main(String[] args) {

        System.out.println("Welcome");

    }
}

Output:

Welcome

5. Advantages of Comments in Java:

  • Comments use pannina code easy-ah understand pannalam.
  • Program-oda purpose-ah explain panna help pannum.
  • Code readability improve aagum.
  • Program maintenance easy-ah irukkum.
  • Mathavanga write panna code-ah understand panna help pannum.

6. Important Points to Remember:

  • Java compiler comments-ah execute pannaadhu.
  • Single-line comments-ku // use pannanum.
  • Multi-line comments-ku /* */ use pannanum.
  • Documentation comments-ku /** */ use pannanum.
  • Comments program execution-ah affect pannaadhu.

Conclusion:

Java programming-la Comments use panradhu romba useful-ah irukkum.

Comments properly use pannina namma code-ah easy-ah read pannavum, understand pannavum, maintain pannavum mudiyum.


                       Java with Suba – Learn Java Step by Step!

Comments

Popular posts from this blog

A Beginner's Guide to Code Logic and Structure📝✨

Introduction to Java☕: Beginner's Complete Guide in Tanglish Version💻✨

Introduction to Java ☕: A Complete Beginner's Guide in English Version💻✨