Please enable JavaScript to use CodeHS

CodeHS Glossary

Comment Java

A message in your code that explains what is going on. Since other people will read through your code, it is helpful to leave messages explaining what is happening in your code. The way you do that is by leaving a comment. Comments in your code are ignored by the computer, which only needs to know the commands. ---------- There are two types of comments. 1: Single line comment // A single line of code with a comment on it. 2: Multi-line comment /* * This comment is longer, so you should split * it onto multiple lines like this. */ You should use Multi-Line comments whenever you have a long comment. You should avoid doing multiple single line comments in a row, even though that does work. Additionally, you should avoid writing a single line comment that wraps around to a new line. The multiline comment starts with `/*` and ends with `*/`. The other `*`’s at the beginning of each other line are not required. They are just for a consistent visual style. ---------- A really good program will have a comment right above each method explaining what it does and one at the top of the program that explains what the program as a whole does.