Comments

Comments are used to improve code readability by providing explanations or notes within the source code. They help developers understand the logic or intent behind specific code blocks.

Example:

// This class represents the Student Object
class Student {
    // This field represents the property of the Student Object
    String name;
    // This represents the behaviour of the Student Object
    void writing() {
        System.out.println("Student is writing");
    }
}

Note: However, the information specified as comments will be ignored by the compiler at the time of compilation. It means, the compiled code will not have any information specified as comments. Hence, comments do not affect the output or performance of the program.

Diagram for understanding comments:

Java Comments Diagram

Types of Comments in Java:

1. Single-line comment :

Used for short, one-line explanations.

// This is a single line comment

2. Multi-line comment :

Used for longer explanations or blocks.

/* This
   is a
   Multi-line
   comment */

3. Documentation Comments (Javadoc) :

Used for generating API documentation using the javadoc tool.

/**
 * This class defines a Student entity.
 * @author ShikshaSanchar
 * @version 1.8
 */
class Student {
    String name;
}

Summary:

  • Comments are used to explain code, making it more readable and maintainable.
  • They are ignored by the compiler and do not affect program execution.
  • Java supports three types of comments:
    1. Single-line (//)
    2. Multi-line (/* */)
    3. Documentation (Javadoc) (/** */) – used to generate official documentation.
  • Using meaningful comments improves collaboration, debugging, and future code updates.

Welcome to ShikshaSanchar!

ShikshaSanchar is a simple and helpful learning platform made for students who feel stressed by exams, assignments, or confusing topics. Here, you can study with clarity and confidence.

Here, learning is made simple. Notes are written in easy English, filled with clear theory, code examples, outputs, and real-life explanations — designed especially for students like you who want to understand, not just memorize.

Whether you’re from school, college, or someone learning out of curiosity — this site is for you. We’re here to help you in your exams, daily studies, and even to build a strong base for your future.

Each note on this platform is carefully prepared to suit all levels — beginner to advanced. You’ll find topics explained step by step, just like a good teacher would do in class. And the best part? You can study at your pace, anytime, anywhere.

Happy Learning! – Team ShikshaSanchar