목록Interface (1)
컴공생의 다이어리
[자바, Java] 인터페이스(interface)
인터페이스(interface) 인터페이스란 다른 클래스를 작성할 때 기본이 되는 틀을 제공하면서, 다른 클래스 사이의 중간 매개 역할까지 담당하는 일종의 추상 클래스를 의미한다. 자바의 다형성을 극대화하여 개발코드 수정을 줄이고 프로그램 유지보수성을 높이기 위해 인터페이스를 사용한다. 인터페이스는 interface 키워드를 통해 선언할 수 있으며 implements 키워드를 통해 일반 클래스에서 인터페이스를 구현할 수 있다. public interface Predator { boolean chasePrey(Prey p); void eatPrey(Prey p); } public class Lion implements Predator { @Override public boolean chasePrey(Prey..
Development/Java
2021. 8. 30. 00:01