인터페이스 와 추상 인터페이스 (interface & abstract interface)
public abstract interface org.springframework.context.ApplicationContext extends ... {
public abstract org.springframework.context.ApplicationContext getParent();
...
}
인터페이스 앞 에 abstract 가 있 는 것 을 발견 하면 추상 인터페이스 (abstract interface) 가 있 습 니 다. 인터페이스 가 모두 추상 적 이지 않 습 니까? 이렇게 쓰 면 무슨 특별한 의미 가 있 는 지 궁금 합 니 다. 인터넷 에 접속 하여 일부 자 료 를 조회 하고, 어떤 네티즌 들 은 유명한 자바 책 에 쓴 인터페이스 에 관 한 논술 을 붙 였 다. 자바 in a nutshell 에서... “All methods of an interface are implicitly abstract, even if the abstract modifier is omitted.” thinking in 자바 에서... “the abstract keyword, which allows you to create one or more methods in a class that have no definitions—you provide part of the interface without providing a corresponding implementation, which is created by inheritors. The interface keyword produces a completely abstract class, one that provides no implementation at all.” 그래서 결론 은 abstract interface 는 interface 이 고 둘 은 전혀 다 르 지 않다 는 것 이다. 그런데 왜 그들 은 그렇게 쓰 려 고 합 니까? 쓸데없는 짓 이 아 닙 니까?jar 가방 에 포 함 된 abstract 를 자동 으로 추가 한 것 이 아 닙 니까? 저 는 소스 코드 를 찾 았 습 니 다. 과연 소스 코드 에는 abstract 가 없습니다.
public interface ApplicationContext extends ListableBeanFactory, HierarchicalBeanFactory,
MessageSource, ApplicationEventPublisher, ResourcePatternResolver {
ApplicationContext getParent();
...
}
그래서 결론 은: interface 는 abstract 를 포함 하고 있 습 니 다. interface 는 abstract interface 와 같은 역할 을 합 니 다. 다만 abstract interface 는 더욱 완전한 표현 일 뿐 입 니 다.
원문 발췌:
http://www.cnblogs.com/sunwei2012/archive/2010/12/10/1902100.html
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
thymeleaf로 HTML 페이지를 동적으로 만듭니다 (spring + gradle)지난번에는 에서 화면에 HTML을 표시했습니다. 이번에는 화면을 동적으로 움직여보고 싶기 때문에 입력한 문자를 화면에 표시시키고 싶습니다. 초보자의 비망록이므로 이상한 점 등 있으면 지적 받을 수 있으면 기쁩니다! ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.