When : 파일, 메서드, 데이터 구조, 알고리즘에 대한 설명
Where : 각 파일의 시작부분, 각 메소드 앞, 함수나 메서드 내부
Attention : 함수나 메서드 내부의 블록 주석은 설명하는 코드와 같게 들여쓰기
public static void main(String[] args) {
/*
* Block comment
*/
}
public static void main(String[] args) {
/*-
* formatting that I want indent(1) to ignore.
* 아래의 양식의 들여쓰기에 맞추어 코드를 실행
*
*one
* two
* three
*/
}
When : 한줄로 주석
Where : 각 파일의 시작부분, 각 메소드 앞, 함수나 메서드 내부
Attention : 함수나 메서드 내부의 블록 주석은 설명하는 코드와 같게 들여쓰기
public static void main(String[] args) {
/* Single-Line Comment */
}
When : 매우 짧은 주석, 코드와 같은 줄에 주석
Where : 각 파일의 시작부분, 각 메소드 앞, 함수나 메서드 내부, 코드 줄
Attention : 코드와 같은 줄에 작성 할때에는 코드와 충분히 띄워 작성, 설명하는 코드와 같게 들여쓰기
public static void main(String[] args) {
int a = 1;
if (a == 2) {
System.out.println("true"); /* special case */
}else {
System.out.println("false"); /* Trailing Comments */
}
}
When : 한줄 또는 여러줄로 주석을 작성할 수 있는 곳
Where : 모든 부분
Attention : 여러줄의 주석 처리는 코드 섹션 주석 처리만 가능(== 텍스트 주석은 block으로!)
public static void main(String[] args) {
int a = 1;
if (a > 2) {
// Do a double-flip.
System.out.println("true");
}else {
System.out.println("false"); //Explain why here.
}
// if (a > 2) {
// // Do a double-flip.
// System.out.println("true");
// }else {
// System.out.println("false"); //Explain why here.
// }
}
When : 파일 문서 작성
Where : 파일 맨 위, 메서드 바로 위
Attention : 태그 사용
/**
* Returns an Image object that can then be painted on the screen.
* The url argument must specify an absolute <a href="#{@link}">{@link URL}</a>. The name
* argument is a specifier that is relative to the url argument.
* <p>
* This method always returns immediately, whether or not the
* image exists. When this applet attempts to draw the image on
* the screen, the data will be loaded. The graphics primitives
* that draw the image will incrementally paint on the screen.
*
* @param url an absolute URL giving the base location of the image
* @param name the location of the image, relative to the url argument
* @return the image at the specified URL
* @see Image
*/
public Image getImage(URL url, String name) {
try {
return getImage(new URL(url, name));
}
catch (MalformedURLException e) {
return null;
}
}
| Order of Tags | Requied | Description of Tags | |
|---|---|---|---|
| 1 | @author | classes and interfaces only | 작성자 |
| 2 | @version | classes and interfaces only, | 현재 버전 |
| 3 | @param(필수) | methods and constructors only | 매개변수에 대한 설명 메서드, 생성자 또는 클래스에 대한 문서 주석 |
| 4 | @return | methods only | 반환타입과 value의 범위를 설명 |
| 5 | @exception | @throws와 동일 메소드에 의해 발생할 수 있는 예외 | |
| 6 | @see | 텍스트, 외부 링트, 다른 필드나 메소드에 대한 모든 참조 링크 | |
| 7 | @since | 설명한 부분이 도입된 버전 | |
| 8 | @serial (@serialField or @serialData) | @serial은 include나 exclude 인수 지정 @serialField 필드에 대한 유형과 설명 @serialData는 특정 직렬화된 메소드 유형 및 순서 등 설명 | |
| 9 | @deprecated | 중지한 API에 대해 사용 중지를 나타내는 설명 |
/**
* @version 1.39, 02/28/97
*/
클래스의 유형 매개변수 예:
/**
* @param <E> 목록에 저장된 요소 유형
*/
public interface List<E> extends Collection<E> {
}
메소드의 유형 매개변수 예:
/**
* @param string
변환할 문자열 * @param type 문자열을 변환할 유형
* @param <T> 요소 유형
* @param <V> 요소 값
*/
<T, V 확장 T> V 변환(문자열 문자열, 클래스<T열 문자열, 클래스<T> 유형){
}
/**
* @see “text”
* @see <a href=”URL”>label</a>
* @see package.class
*/
/**
* @since 1.10
*/