Mohamed Maher
Mohamed Maher

Reputation: 11

how to pops and returns the character at the top of the Stack?

Stack s=new Stack();
LinkedList qeue = new LinkedList();

public void pushCharacter(char ch) {
    s.push(ch);
}
public void enqueueCharacter(char ch) {
    qeue.addLast(ch);
}
public char popCharacter() {
    s.pop();
    return  // ?11
}

Upvotes: 1

Views: 38

Answers (1)

Andrew
Andrew

Reputation: 49636

return s.pop();

Stack#pop "removes the object at the top of this stack and returns that object as the value of this function". You must have a Stack<Character>, though. Don't use raw types.

Upvotes: 1

Related Questions