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

  • International Nurses Day in Hindi | नर्स दिवस क्यों मनाते हैं?
    International Nurses Day in Hindi | नर्स दिवस क्यों मनाते हैं? General Knowledge
  • Unicef day
    Unicef day is celebrated on December 11 | Speech on unicef day General Knowledge
  • Human rights day
    Human rights day in Hindi: 10 दिसंबर ह्यूमन राइट्स डे General Knowledge
  • Fundamental Rights of Indian Citizens
    Fundamental Rights of Indian Citizens | मौलिक अधिकार क्या हैं? General Knowledge
  • Why is Makar Sankranti celebrated
    Why is Makar Sankranti celebrated? Festival
  • Subhas Chandra Bose Biography in Hindi, Essay, Paragraph
    Subhas Chandra Bose Biography in Hindi, Essay, Paragraph Biography
  • Farmers Day
    National Farmers Day in Hindi | राष्ट्रीय किसान दिवस पर निबंध | चौधरी चरण सिंह जयंती General Knowledge
  • Elon musk Hindi : एलन मस्क हिंदी में, Autobiography,  Net Worth
    Elon musk Hindi : एलन मस्क हिंदी में, Autobiography,  Net Worth Biography

Java Comments : Types of java comments, Syntax & Examples

Posted on August 14, 2021May 5, 2022 By GeekCer Education
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 11 new Features (With example Programs) Java 11 new Features (With example Programs) Important
Java Learning Tutorial Java Tutorial for Advanced Learning, Buzzwords, Parts of Java Java
Multithreading in java Multithreading in java, Thread, Runnable | Life Cycle of Thread Java
Java ArrayList Java ArrayList Java
Lambda Expression in Java 8 | Functional Interface | Example Lambda Expression in Java 8 | Functional Interface | Example Java
Difference between StringBuffer and StringBuilder Difference between StringBuffer and StringBuilder Differences
  • 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
  • National Farmers Day in Hindi | राष्ट्रीय किसान दिवस पर निबंध | चौधरी चरण सिंह जयंती
  • Human rights day in Hindi: 10 दिसंबर ह्यूमन राइट्स डे
  • Unicef day is celebrated on December 11 | Speech on unicef day
  • Indian Navy Day: जल सेना दिवस कब और क्यों मनाया जाता है?
  • P V Sindhu Biography in Hindi, Badminton, State, Caste पी. वी. सिंधु जीवन परिचय, कहानी, राज्य, जाति
  • Draupadi Murmu Biography In Hindi | द्रौपदी मुर्मू की जीवनी
  • IPv4 Vs IPv6 | Difference between IPv4 and IPv6
    IPv4 Vs IPv6 | Difference between IPv4 and IPv6 Differences
  • Difference between Internet and Intranet
    Difference between Internet and Intranet Differences
  • Difference between TCP and UDP
    Difference between TCP and UDP | TCP vs UDP examples Differences
  • TCP/IP Model, Full Form, Layers and their Functions
    TCP/IP Model, Full Form, Layers and their Functions Networking
  • Similarities and difference between OSI and TCP/IP model
    OSI vs TCP/IP Model, Similarities and difference between OSI and TCP/IP model Networking
  • Network kya hai (नेटवर्क क्या है)
    Network kya hai (नेटवर्क क्या है) Networking
  • OSI Model | 7 Layers of OSI Model in Computer network
    OSI Model | 7 Layers of OSI Model in Computer network, Functions Networking
  • 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