I am having a hard time with interfaces. I know that if a Class Implements the interface it must provide concrete methods that the Interface uses, but here is my problem. Class HttpServlet Implements Servlet, Servlet Config and Serializable. Yet in most of it's methods it uses a reference to an HttpServlet. The HttpServlet is an Interface but it is not implemented. How is this allowed? I see alot of the Classes in Java doing this, and I am having a hard time understanding how. Thanks Mike Mann
Mike Mann
Greenhorn
Joined: Nov 21, 2003
Posts: 4
posted
0
Need to Clarify my last.It uses an HttpServletRequest Interface as an Reference.
Ernest Friedman-Hill
author and iconoclast
Marshal
then a variable of type HttpServletRequest can legally refer to a SomeClass object; a SomeClass is an HttpServletRequest. Therefore, if a method takes an HttpServletRequest as a parameter, that means that to call it, you would have to pass an instance of an object that implements that interface. This is really the whole point of interfaces; they let you specify what a class should look like, and make use of an instance of that class, without naming the actual class.