Comments in Java – Kensoft PH https://kensoftph.com Power up your knowledge in programming Mon, 28 Feb 2022 04:56:20 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.1 https://kensoftph.com/wp-content/uploads/2021/07/cropped-Kensoftph-New-logo-32x32.png Comments in Java – Kensoft PH https://kensoftph.com 32 32 Comments in Java | 100% Perfect for beginner https://kensoftph.com/how-to-write-comments-in-java-perfect-for-beginner/ https://kensoftph.com/how-to-write-comments-in-java-perfect-for-beginner/#respond Sun, 06 Feb 2022 14:29:14 +0000 https://kensoftph.com/?p=1908 Commenting in your Java code is important so that other developers can easily read and understand your code. Comment implementations are intended for commenting out code or commenting on how the code works in a specific implementation. Comments give extra information if the code is difficult for other developers to understand.

In this short tutorial, I will explain the 3 types of comments in Java. Writing application code in Java is easy, especially when some parts of the code are commented to provide more information for other developers; not just for others, but also for you as a developer. The information provided below is perfect for you.

How to write comments in Java

It is simple to write comments in Java, you only need to understand the different types of comments in Java before you begin commenting your Java code. These types of comments are simple to learn and understand. Learn more below.

Types of comments in Java

These are the 3 types of comments in Java; Single-line, Multi-line, and Documentation comments. These comments are important and easy to learn and remember, especially for you as a beginner.

Comments in Java

Single-Line Comment

Single-line comments start with two forward slashes //. Java will ignore any text after the two forward slashes. This means that Java will not execute the text after these forward slashes. The Single-Line comment is widely used and easy to implement. Simply type the two forward slashes.

Example

// This is a Single-Line comment
System.out.println("KensoftPH.com");

Comments in Java

Multi-Line Comment

Multi-Line Comment is another name for (Block Comments). Multi-Line comments are used to describe files or to provide more explanation to the code. Java will ignore any text between /* and */. This means that the text between /* and */ will not be executed by Java.

Example

/* This is an example of
   Multi-Line Comments */
System.out.println("KensoftPH.com");

Comments in Java

Documentation Comment

It is one the three types of comments in Java. Documentation comment is commonly used to describe Java Classes, interfaces, constructors, and fields. If you wonder how it looks like, Documentation comments looks like this: /**...*/. Learn more about the Documentation comments in Java.

Example

/**
 * This is an example of Documentation comment
 */
public class DocComment { ...

]]>
https://kensoftph.com/how-to-write-comments-in-java-perfect-for-beginner/feed/ 0