我的理解:
1,接口中没有实现具体方法
2,接口不能实例化
我的问题是,在没有类实现该接口的时候,为什么程序中能够调用某方法返回该接口并且执行该接口中定义的方法?
例如petstore112中:
requestMappingsURL = getServletContext().getResource("/WEB-INF/xml/requestmappings.xml").toString();
其中 getServletContext()是 Returns a reference to the ServletContext object in which the servlet is executing.
getResource()是ServletContext 中声明的方法
但是,我看过java帮助,ServletContext是interface,为什么这里可以返回一个ServletContext对象的reference?
这是怎么回事?我彻底糊涂了,本来就是新手:-(
请指教,谢谢