본문 바로가기
Java 배우기

Wildcards 와일드카드

by 노화방지 Anti-aging Hairstyle 2016. 1. 24.
반응형

와일드카드 Wildcards


제네릭 코드에서, 와일드카드 라고 하는 물음표 (?)는 알 수 없는 타입을 나타냅니다.
와일드카드는 다양한 상황에서 사용될 수 있습니다: 매개변수의 타입, 필드 또는 로컬변수로; 때로는 반환 타입으로 (보다 구체적인 프로그래밍 습관이 바람직하지만).
와일드카드는 제네릭 메소드 호출에 대한 타입 아규먼트, 제네릭 클래스 인스턴스 생성 또는 슈퍼타입으로 는 사용되지 않습니다.

다음 섹션에서는 상위 경계 와일드카드, 낮은 경계 와일드카드 및 와일드카드 캡처를 포함한 와일드카드를 보다 상세하게 설명합니다.

In generic code, the question mark (?), called the wildcard, represents an unknown type. The wildcard can be used in a variety of situations: as the type of a parameter, field, or local variable; sometimes as a return type (though it is better programming practice to be more specific). The wildcard is never used as a type argument for a generic method invocation, a generic class instance creation, or a supertype.

The following sections discuss wildcards in more detail, including upper bounded wildcards, lower bounded wildcards, and wildcard capture.


반응형

댓글