○Interface
▷class가 해야할 일을 명시하는 일종의 signature class
▷정의되지 않은 메소드들을 가진다.
▷abstract class와 비슷하다.
▷여러 Class에 대해 일반화된 함수를 지원해줌. ( ex) 다른 Class간의 비교 )
▶선언
▷Class와 비슷한 방식으로 선언한다. (class 대신 interface)
▷메소드를 선언만 하고, 정의하지 않는다.

▶포함 (implements)
▷Class는 interface를 implements할 수 있다.
▷implements한 interface의 모든 method를 정의해야 한다. (abstract class와 비슷)
▷한번에 여러 개의 interface를 implements할 수 있다. (,를 통해 구분)

▶Interface variable
▷Abstract Class와 다르게, Interface 타입의 변수를 선언할 수 있다.
▷해당 Interface를 포함한 모든 Class가 변수에 들어갈 수 있다.

▶Default Interface Method (Java8)
▷default 키워드를 통해 기본 implement를 정의 가능함.
▷implementes되었을때, 자동으로 default method를 생성하게 됨.

▶Default Interface Methodd Extends (상속)
▷extends: default method 상속함.

▷extends + redeclare: default method가 abstract하게 됨.

▷extends + redefine: default method를 override함.

▶Static Interface Method (Java8)
▷Interface의 이름으로 접근 가능한 Method.
▷내용이 정의될 수 있다.
▷다른 default, static method에 접근 가능하다.
'컴퓨터 언어 > java' 카테고리의 다른 글
Lambda Expression (0) | 2020.11.16 |
---|---|
Collection (0) | 2020.11.16 |
Inheritance (0) | 2020.11.14 |
Package (0) | 2020.11.13 |
Inner class (0) | 2020.11.11 |