In this lesson, we will learn to write explanatory comments within a Java program.

Why use comments

Novice programmers tend to omit comments. But comments provide an opportunity for us to document our thoughts about what our program does and how it solves the problem at hand. Although comments are important to others who read our program, we should realize that they are useful to us, too. Typical programs are written over a period of time. What might be obvious to you today could be baffling next week.

See the program given below:

Get hands-on with 1200+ tech skills courses.