Originally posted by johny doe:
when i tried to understand a certain code
i got interface called Stack
and a stack class called StackAsArray
1.why are they creating a stack variable called
StackAsArray s = new StackAsArray();
Carefully look at the code. An instance of a
class StacksArray has been created and NOT of interface Stack.
Stack has no meening it just an interface which inculdes all the method wich we need to create inside of StackAsArray class.
???
Yes. very true. You don't need to create but define the methods inside the StacksArray class provided if it implements the Stack interface.
Obviously, you don't need an object for an interface and you can't do so. The compiler makes sure the same.
[ January 01, 2008: Message edited by: Raghavan Muthu ]