Comments in java code

Comments are the essential part of code. If you write good comments, it will be easier for others to understand the code. Comments are ignored by the compiler when it compiles the program.

There are three types of comments in java code.

  1. Single line comments
  2. Multi-line comments
  3. Java doc comments

Single line comments:

These are most used java comments. It is used to comment a single line.

For example:

Multi line comments:

If you want to write comments in multiple line, single lines comments may be tedious to write.In this situation, you can use multi line comments.

For example:

Javadoc comments:

If you want to generate javadoc for your class, you can use javadoc comments. When you run javadoc command, it automatically generate javadoc with javadoc comments

For example:

Comments are most important part of code. You should use them as and when required.

Related Posts

  • 25 September

    Reference Variable in Java

    In this post, we will see about Reference variable in java. Reference variable A variable that holds reference of an object is called a reference variable. Variable is a name that is used to hold a value of any type during program execution. If the type is an object, then the variable is called reference […]

  • 26 March

    Global variables in java

    In this post, we will see how to define global variables in java. Unlike C/C++, there are no standard global variables in java but you can still define global variables that can be used across all classes. Global variables are those variables that can be accessed across all the classes. Java does not support global […]

  • 26 March

    Static block in java

    In this post, we will see about how to implement static block in java. Here are some important points about static block in java. Static block is used for static initializations of a class Static block is executed only once when either you create an object of the class or access static member of the […]

  • 26 August

    Java default constructor

    In this post, we will see about Java default constructor. Default constructor is the no arg constructor which is inserted by compiler unless you provide any other constructor explicitly. You won’t able to see it as it is present in class file rather than source file. Is there any difference between no argument constructor and […]

  • 17 June

    How to learn Java Programming

    Java is one of the most used programming languages in the world for developing the desktop application and web application.It has completed 22 years in the programming world. In this post, we will see how to learn java programming in depth and in most efficient way. Java has a huge learning curve, it is a […]

  • 28 May

    Introduction to Java Programming

    Java is one of the most used programming languages in the world for developing desktop application and web application. It has completed 22 years in the programming world. History of Java: Java programming language was developed by James Ghosling, Patrick Naughton, Mike Sheridan at Sun Microsystems Inc. in 1991. The initial name was Oak but […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.