Skip to content
  • Facebook
GeekCer Logo

GeekCer

The geek's Coding education and Review centre

  • Home
  • Tutorials
    • Java
    • Servlet
    • JSP
    • Python
    • C Tutorial
    • Spring
    • Spring Boot
    • MongoDB
    • Hibernate
    • Data Structure
  • General Knowledge
  • Biography
  • Grammar
  • Festival (त्योहार)
  • Interview
  • Differences
  • Important
  • Toggle search form

Home » Java » Java Comments : Types of java comments, Syntax & Examples

  • Java 8 interview questions and answers, Java Stream, Optional
    Java 8 interview questions and answers, Java Stream, Optional Important
  • Structure in C program with example | Nested structure in C
    Structure in C program with example | Nested structure in C C Language
  • Java ArrayList
    Java ArrayList Java
  • Why is Makar Sankranti celebrated
    Why is Makar Sankranti celebrated? Festival
  • What is Verb
    What is Verb? Types of Verbs and Examples Grammar
  • Yrkkh - Yeh Rishta Kya Kehlata Hai Serial, Episode, Cast
    Yrkkh – Yeh Rishta Kya Kehlata Hai Serial, Episode, Cast News
  • Constants and Operators in C Language
    Constants and Operators in C Language C Language
  • Collections in Java
    Collections in Java Java

Java Comments : Types of java comments, Syntax & Examples

Posted on August 14, 2021May 5, 2022 By admin
Java Comments

Java Comments are description about the feature and working of a program. By using comments you describe the nature and flow of the program, functionality of the program.

Comments help others to follow our code easily and comments make the code more readable and understandable.

Comments are an integral part of any programming language like Java, C#, Python, C, C++. Comment helps the developer to read the code for better understanding.

There are three types of comments in Java:

  • Single Line comments
  • Multi line comments
  • Documentation Comments

Table of Contents

  • Single line Comments in Java
  • Multiline Comments in Java
  • Java documentation comments
  • Single Line comment in multiple line in Java
  • What is an API documentation?

Single line Comments in Java

When you need to mark a single line as a comment then you should go for Single line comment. These comments start with double slash symbol //. And whatever is written till the end of the line

 
 // This is single line comment 

Multiline Comments in Java

When you need to mark several lines as a comment then you should go for Multiline comment. These comments start with /* and ends with */.

 
 /* 
This is multi line comment
Statement 1 
Statement 2 
Statement 3 
*/

Java documentation comments

Such comment starts with /** and ends with */. When you need to describe the every feature of the program then you should prefer the documentation comment. It is helpful to create a .html file API documentation.

You should use java documentation before every feature in the program.


 /** Description about interface and class */
class Example {

}

 /** 
* Description about a method of the class
* in multiline
*/
public static void main(String[] args) {

}

Single Line comment in multiple line in Java

Normally we use // for short comment and /* */ for long comment or multiline. It’s upto you which you want to use for you code.

 
// Statement 1 
// Statement 2 
// Statement 3 

What is an API documentation?

An API document is basically a .html file which contains details about all the features of an application, product, technology. By using API documentation gives the user an understanding of how to use the software and technology.

In Java, you should use a special compiler javadoc to generate the API documentation of the software.

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • More
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)

Also Read

Java Tags:Comments, HTML, JavaDoc

Post navigation

Previous Post: Java Tutorial for Advanced Learning, Buzzwords, Parts of Java
Next Post: Variables in Java

More Related Articles

Java Switch Case Java Switch Case Java
Java 11 new Features (With example Programs) Java 11 new Features (With example Programs) Important
Java 8 interview questions and answers, Java Stream, Optional Java 8 interview questions and answers, Java Stream, Optional Important
Lambda Expression in Java 8 | Functional Interface | Example Lambda Expression in Java 8 | Functional Interface | Example Java
Difference between Runnable and Callable in Java Difference between Runnable and Callable in Java Differences
Java LinkedList Java LinkedList Java

Related Posts

  • Java Switch Case
    Java Switch Case Java
  • Java 11 new Features (With example Programs)
    Java 11 new Features (With example Programs) Important
  • Java 8 interview questions and answers, Java Stream, Optional
    Java 8 interview questions and answers, Java Stream, Optional Important
  • Lambda Expression in Java 8 | Functional Interface | Example
    Lambda Expression in Java 8 | Functional Interface | Example Java
  • Difference between Runnable and Callable in Java
    Difference between Runnable and Callable in Java Differences
  • Java LinkedList
    Java LinkedList Java
  • Java Home
  • Java Comments
  • Java Variables
  • Java Data Types
  • Java Keywords
  • Java Operators
  • Java If-else Statement
  • Java Switch
  • Java Loop
  • Java Arrays
  • Method Overloading in Java
  • Java OOP
  • Java Collections
  • Java ArrayList
  • Java LinkedList
  • Java Vector
  • Multithreading in java
  • Thread Synchronization
  • Exception Handling
  • Java JDBC Driver
  • Java Database Connectivity steps
  • Lambda Expressions
  • Concurrent Collections

Recent Posts

  • Structured Vs Unstructured Data in Hindi | Key Difference
  • Jhansi Ki Rani Lakshmi Bai History, Story, Information in Hindi
  • Elon musk Hindi : एलन मस्क हिंदी में, Autobiography,  Net Worth
  • World Environment Day in Hindi : Objective, Importance, Theme
  • Thomas Edison Biography in Hindi – थॉमस एडिसन जीवनी
  • International Nurses Day in Hindi | नर्स दिवस क्यों मनाते हैं?
  • Fork/Join Framework in Java | RecursiveTask, RecursiveAction
  • DBMS in Hindi | DBMS क्या है? | DBMS की विशेषताएं और प्रकार
  • Java 8 interview questions and answers, Java Stream, Optional
    Java 8 interview questions and answers, Java Stream, Optional Important
  • Structure in C program with example | Nested structure in C
    Structure in C program with example | Nested structure in C C Language
  • Java ArrayList
    Java ArrayList Java
  • Why is Makar Sankranti celebrated
    Why is Makar Sankranti celebrated? Festival
  • What is Verb
    What is Verb? Types of Verbs and Examples Grammar
  • Yrkkh - Yeh Rishta Kya Kehlata Hai Serial, Episode, Cast
    Yrkkh – Yeh Rishta Kya Kehlata Hai Serial, Episode, Cast News
  • Constants and Operators in C Language
    Constants and Operators in C Language C Language
  • Collections in Java
    Collections in Java Java
  • Java Tutorial
  • Servlet Tutorial
  • JSP Tutorial
  • Maven Tutorial
  • HTML Tutorial
  • Programs
  • Hindi/English Grammar
  • Difference Between ... and ...
  • HR Interview
  • Important Articles

Write to Us:
geekcer.code@gmail.com

  • About Us
  • Privacy and Policy
  • Disclaimer
  • Contact Us
  • Sitemap

Copyright © GeekCer 2022 All Rights reserved