Java/Language Basics/Java Doc Comments — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 06:47, 1 июня 2010
Comments demo
/**
* The <code>Bar</code> component doesn"t do much of anything. It is just
* meant to demonstrate javadoc.
* <p>
*
* @version 2.4
* @author John Zukowski
*/
public class Bar {
/**
* A specific type of foo
*/
public static final int FOO_TYPE = 0;
/**
* Another specific type of foo
*/
public static final int ANOTHER_FOO_TYPE = 1;
/**
* The current foo type
*/
private int type;
/**
* Constructs a Bar
*/
public Bar() {
type = FOO_TYPE;
}
/**
* Returns current foo type
*
* @return current foo type
* @deprecated As of version 2.3, use {@link #getFoo() getFoo()}instead
*/
public int foo() {
return getFoo();
}
/**
* Returns current foo type
*
* @return current foo type
* @since V2.3
*/
public int getFoo() {
return getFoo();
}
/**
* Changes current foo type
*
* @param type
* new type of foo
* @throws IllegalArgumentException
* When type invalid
*/
public void setFoo(int newValue) {
if ((newValue != FOO_TYPE) && (newValue != ANOTHER_FOO_TYPE)) {
throw new IllegalArgumentException("Bad type");
}
type = newValue;
}
/**
* Placeholder method for see tags
*
* @see Bar#FOO_TYPE
* @see Bar#getFoo()
* @see #getFoo()
* @see "My Book"
* @see
*/
public void myVoid() {
}
}
How to write Comments
public class Comment {
// This is a one-line comment; it extends to the end of the line.
/*
* This is a delimited comment, extending over several lines.
*/
int /* This delimited comment extends over part of a line */x = 117;
}