if u asked to implement a stack using an ArrayList given the the stack interface,do i have to create a stack class that extends arraylist after i create the one that implements stack interface....?
May some one briefly explain wat implementing stack using a arraylist mean.?do they mean stack inherits arraylist properties or wat?
Re: stack implementation
I'm hesitant to say that extending ArrayList as ArrayListStack is the correct solution here because this would allow more access than a true Stack should allow. This isn't necessarily a bad thing, but you need more solid specifications before a good recommendation can be made.
In general, I would prefer a composition solution. Your stack implementation class would use an ArrayList internally for storing the stack state, but it would not be an ArrayList because an ArrayList provides RandomAccess which a stack shouldn't have.