티스토리 뷰

반응형
 

Defining Methods (The Java™ Tutorials > Learning the Java Language > Classes and Objects)

The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available. See Java Language Changes for a summary of updated

docs.oracle.com

TL;DR

  • 메소드 시그니쳐: 메소드명 + 매개변수 타입들
Definition: 
Two of the components of a method declaration comprise the method signature
- the method's name and the parameter types.

// 메소드 시그니쳐는 메소드를 선언하는 구성 요소 중 두 가지로 이루어진다. - 메소드명, 매개변수 타입들

 

e.g.

  • 어떤 클래스 안에 다음과 같은 메소드를 작성했다고 하자.
public double calculateAnswer(double wingSpan, int numberOfEngines, double length, double grossTons) {
    //do the calculation here
}
  • 이 경우, 메소드 시그니쳐는 '메소드명'과 '매개변수의 타입'으로 구성되므로 다음과 같다.
calculateAnswer(double, int, double, double)

 

  • 많은 글들이 메소드명과 매개변수 리스트의 조합을 메소드 시그니쳐로 소개한다. 공식 문서에는 parameter types로 나와 있으나, 매개변수 리스트와 매개변수 타입들을 너무 엄격하게 따져 알아둘 필요는 없을 듯 하다.
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함