https://atoz-develop.tistory.com/entry/JAVA-8-interface-default-키워드와-static-메소드

인터페이스는 개발 코드와 객체가 서로 통신하는 접점 역할을 한다. 그렇기 때문에 개발 코드는 객체의 내부 구조를 알 필요가 없고 인터페이스의 메소드만 알고 있으면 된다.

인터페이스의 존재 이유는 개발 코드를 수정하지 않고, 사용하는 객체를 변경할 수 있도록 하기 위해서이다.

The default method in interface

public interface ICalculator {
	int add(int x, int y);
	int sub(int x, int y);

	default int mul(int x, int y) {
		return x * y;
	}
}
// The "mul" is default method in interface

public class Calculator implements ICalculator {
	@Override
	public int add(int x, int y) {
	 return x + y;
	}
	@Override
	public int sub(int x, int y) {
		return x - y;
	}
}

public class CalcTest {
	public static void main(String[] args) {
		ICalculator cal = new Calculator();
		int result = cal.mul(5, 3);
		System.out.println("5 * 3 = " + result); 
	}
}
// Even though the "mul" method hasn't been implemented in the Calculator class, it can be invoked and used because it's implemented in the ICalculator interface with the default keyword.

The static method in an interface

public interface ICalculator {
	int add(int x, int y);
	int sub(int x, int y);

	static void print(int value) {
		System.out.println(value);
	}
}

public class CalcTest {
	public static void main(String[] args) {
		ICalculator cal = new Calculator();
		ICalculator.print(100);
	}
}
// Static method in an interface must be invoked using the name of the interface.

타입 변환

Television tv = new Television

RemoteControl rc = new Television

// 해석 텔레비전이라는 구현객체를 RemoteControl 인터페이스를 통해서 사용한다.