0

I'm trying to implement an stack using a linked list in Java, But I'm not sure which methods I have to implement(stack is a simple example here), How can I somehow get the methods and then extend my linked list class to implement my own class of stack

I know that somehow I have to use some kind of interface but it would be a great help if someone could guide me here.

8
  • 1
    How to implement an already well implemented module in java what does it mean even?? Commented Jan 5, 2014 at 16:32
  • @sᴜʀᴇsʜᴀᴛᴛᴀ see the description please! Commented Jan 5, 2014 at 16:34
  • 1
    You can have a look at the Stack class from the API to see which methods to implement : docs.oracle.com/javase/7/docs/api/java/util/Stack.html Commented Jan 5, 2014 at 16:46
  • 1
    Ali, Something like this ?? stackoverflow.com/questions/12056784/… and this stackoverflow.com/questions/13638289/… Commented Jan 5, 2014 at 16:46
  • 1
    Java doesn't have modules! I suggest you don't ever mention the word module if you want to pass a Java interview. Commented Jan 5, 2014 at 16:58

1 Answer 1

4

A stack at its simplest just has Push() and Pop(). They map directly to the LinkedList methods push and pop already present!

So in order to implement a stack on top of a linked list you need to do....nothing :)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.