ran into a little snag with my code. i am trying to push the data of all the nodes in a linkedlist into a stack. problem is, i have no idea how to properly convert a node into a variable.

Node current = list.returnHeadNode();
//other code...
stack.push(current.getData());

my error lies in here somewhere. can someone explain to me why this does not work and what i can do to fix it?

Recommended Answers

All 2 Replies

this is a clue...

public stack <datatype> foo = new stack<datatype> foo();
public Node <stack> nfoo = new Node<stack> nfoo();

now you can put stack into node.

i have never seen a solution like that. i need something that uses just pointers, if that makes any sense.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.