A comment is text that the compiler ignores but is useful for programmers. Comments are typically used to annotate code for reference. The compiler treats them as spaces. You can use comments during the test to make certain lines of code inactive.
// single-line comment
/*
mulit-line
comment
*/
/**
* documentation comments (Javadoc)
* Javadoc is a documentation generator
* some common elements are included, like:
*
* @author (Author name)
* @version (Version number)
* @param (Parameters to add)
* @return (return type/value)
* @exception (or @throws)
* @see
* @since
* @serial (or @serialField or @serialData)
* @deprecated
*/
public class Comments {
/**
* add function
* @param x integer value to add
* @param y integer value to add
* @return addition of this two parameters
*/
private static int add(int x, int y) {
return x + y;
}
/* args contains the command-line arguments
passed to the Java program upon invocation.*/
public static void main(String[] args) {
// Variable declaration and initialization
int x = 2, y = 5;
// Output
System.out.print(add(x, y));
}
}
7