Inline Code Documentation
suggest changeApart from Javadoc, code can be documented inline.
Single Line comments are started by // and may be positioned after a statement on the same line, but not before.
public void method() {
//single line comment
someMethodCall(); //single line comment after statement
}
Multi-line comments are defined between /* and */. They can span multiple lines and may be positioned between tokens.
public void method(Object object) {
/*
multi
line
comment
*/
object/*inner-line-comment*/.method();
}
JavaDocs are a special form of multi-line comments, starting with /**.
As too many inline comments may decrease readability of code, they should be used sparsely in case the code isn’t self-explanatory enough or the design decision isn’t obvious.
Single-line comments are also used for tags: short, convention-driven keywords. Some development environments recognize these comments. Common examples are
//TODO//FIXME
Or issue references, i.e. for Jira
//PRJ-1234
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents