실무

반응형

    JAVA Basic) 인터페이스 활용

    목차 한 클래스가 여러 클래스를 상속받으면 메서드 호출이 모호해지는 문제가 발생할 수 있다. 하지만 인터페이스는 한 클래스가 여러 인터페이스를 구현할 수 있다. package interfaceex; public interface Buy { void buy(); } package interfaceex; public interface Sell { void sell(); } 그림을 보면 Customer클래스는 Buy와 Sell 두 인터페이스를 구현하고 있다. Buy인터페이스에 추상 메서드 buy()가 선언. Sell인터페이스에 추상메서드 sell()이 선언. package interfaceex; public class Customer implements Buy, Sell{ // Customer클래스는 Buy와..

반응형