주석문
주석이란?
프로그램의 코드와 실행에는 영향을 주지 않는 문장
주석의 종류
(1) 구현 주석
- 행단위 주석( // )
- 블럭단위 주석( /* 내용 */)
(2) 문서화 주석
- /** 문서에 포함할 내용 */
- 문서화 주석은 클래스, 인터페이스 그리고 멤버 당 하나씩 가질 수 있고, 선언 바로 전 작성
문서화 주석 예시
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);
}
}
주석문 실습
https://school.programmers.co.kr/learn/courses/5/lessons/147
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
정답 코드
public class HelloWorld {
public static void main(String[] args) {
// 이 부분을 주석처리 해서 프로그램이 정상적으로 실행되도록 만들어 보세요.
System.out.println("HelloWorld");
}
}
출처 : https://school.programmers.co.kr/learn/courses/5/lessons/108
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
'Java' 카테고리의 다른 글
[자바 입문] 기본형 타입 변환 (0) | 2023.08.10 |
---|---|
[자바 입문] 기본형 타입 (0) | 2023.08.10 |
[자바 입문] 상수 (0) | 2023.08.10 |
[자바 입문] 변수 (0) | 2023.08.10 |
[자바 입문] 자바란? (0) | 2023.08.10 |