Learning Java Series — Part 1 — Comments In Java

Learning the basics is the most important way to learn anything. To learn a language also, you need to begin from the basics which are why I have decided to learn the Java Programming language again from the beginning.
I would try to explain what I have learned when I read with the hope that others would indeed learn and I would also become better in the process.
So I would be talking about Comments In Java Today. So what is a comment in the context of a programming language? A comment is a piece of information that is meant to shed more light on a certain piece of code. It is meant for humans to fully grasp the meaning of a certain code without having to spend much time understanding the implementation of the code.
Comments are necessary for that they aid readability of programming languages. In Java, there are 3 forms of comments. We have
- The Single Line Comment
- The Multi Line Comment
- Documentation Comment
The Single Line Comment is usually used to give a line or a few lines of comments. It starts with a (Double Back Slash) // and everything on that line becomes a comment. Single line comments are very important because we sometimes need to make very short comments and this is the basic way to achieve a single line of comment. An example of a single line comment is
// Welcome to The Java World
The whole line above is now a comment. The compiler does not attend to it when it compiles the code and is only useful for the human programmer.
Multi Line Comment is used when you have a little more comments than a few lines can take. You use a multi line comment which allows a number of lines to be commented without having to use multiple single line comments. An example of a multi line comment is
/*
Every thing within here is a comment
- /
Documentation Comment is similar to the multi line comment except in very few ways. The documentation comment is used to have a large note to serve as comments. These types of comments are usually needed if the comment is to be transferred to another page maybe like a website.
/**
This is a document comment
- /
All these forms of comments are needed to help make our code readable. But ensure that your code is so readable that comments are barely found anywhere in your code. You would need to use comments no matter what, but kindly reduce it to a bare minimum. It helps.
Please do submit your observations and recommendations to help make this better. Thanks for Reading
