Java/References

[JAVA] Method Signature, Method Type, Method Reference

defacto standard 2018. 5. 1. 17:08

Method Signature

1. 메서드의 이름

2. 메서드의 파라미터 타입



Method Type

1. 메서드의 리턴 타입

2. 메서드 타입 파라미터

3. 메서드 인자 타입

4. Exception



Method Signature가 같다고 Method Reference를 쓸 수 있는게 아니라,

Method Type이 같아야 Method Reference를 쓸 수 있다.


이는 상속관계에서, 부모클래스의 메서드가 있을 때, 자식클래스의 메서드에서 오버라이딩을 할 수 있는 조건에 해당한다.


따라서 Super super = new Sub(); super.a()와 같은 Method Reference가 가능해진다.