한줄정리: 주석은 설명하는 것이고, 쓰는 방법으로는//내용, /*내용*/,/** 문서화내용*/종류가 있다!
주석이란, 프로그램의 코드와 실행에는 영향을 주지 않는 문장
주석의 종류
- 구현 주석
- 행단위 주석 (// 를 해주면, 해당 행이 주석 처리됨 )
- 블럭단위 주석 (/* 주석으로 사용할 내용 */ )
- 문서화 주석
- /** 문서에 포함할 내용을 작성함 */
- 문서화 주석은 클래스, 인터페이스 그리고 멤버 당 하나씩 가질 수 있고, 선언 바로 전에 작성
- 문서화 주석 예
import java.io.*; /** * <h1>Add Two Numbers!</h1> * The AddNum program implements an application that * simply adds two given integer numbers and Prints * the output on the screen. * <p> * <b>Note:</b> Giving proper comments in your program makes it more * user friendly and it is assumed as a high quality code. * * @author Zara Ali * @version 1.0 * @since 2014-03-31 */ public class AddNum { /** * This method is used to add two integers. This is * a the simplest form of a class method, just to * show the usage of various javadoc Tags. * @param numA This is the first paramter to addNum method * @param numB This is the second parameter to addNum method * @return int This returns sum of numA and numB. */ public int addNum(int numA, int numB) { return numA + numB; } /** * This is the main method which makes use of addNum method. * @param args Unused. * @return Nothing. * @exception IOException On input error. * @see IOException */ public static void main(String args[]) throws IOException { AddNum obj = new AddNum(); int sum = obj.addNum(10, 20); System.out.println("Sum of 10 and 20 is :" + sum); } }
'Java' 카테고리의 다른 글
Java 기초 시리즈 - 4 기본형타입이란? (0) | 2022.01.28 |
---|---|
Java 기초 시리즈 - 3 상수란? (0) | 2022.01.27 |
Java 기초시리즈 -2 변수란? (0) | 2022.01.27 |
Java란? (0) | 2021.12.28 |