Friday 23 March 2018

Comment line in java

Comments allow us to place any form of documentation inside our Java code. They can
contain anything that we can type on the keyboard: English, mathematics, even lowresolution
pictures. In general, Java recognizes comments as tokens, but then excludes
these tokens from further processing; technically, it treats them as white space when it is
forming tokens.
Comments help us capture aspects of our programs that cannot be expressed as Java
code. Things like goals, specification, design structures, time/space tradeoffs, historical
information, advice for using/modifying this code, etc. Programmers intensely study their
own code (or the code of others) when maintaining it (testing, debugging or modifying
it). Good comments in code make all these tasks much easier.
Java includes two styles for comments.
(1) Line-Oriented:- begins with // and continues until the end of the line.
(2) Block-Oriented:- begins with /* and continues (possibly over many lines) until */
is reached.
o So, we can use block-oriented comments to create multiple comments within a
line
display (/*Value*/ x, /*on device*/ d);
In contrast, once a line-oriented comment starts, everything afterward on its
line is included in the comment.
We can also use block-oriented comments to span multiple lines
/*
this is a multi-line comment.
No matter home many lines
it includes, only one pair
of delimiters are needed
*/

No comments:

Post a Comment