weixin_38393017
weixin_38393017
2017-07-28 14:54

java栈的链表实现问题

  • java
  • 链表

这个push入栈方法是怎么实现的,每条语句都分别是什么意思

public class Stack implements Iterable{
private Node first;
private int n;
private static class Node{
private Item item;
private Node next;
}
------------------------------------------------------------------------------
public void push (Item item) {
Node oldfirst = first ; //??
first = new Node(); //??

    first.item=item;                //??
    first.next=oldfirst;                //??
    n++;
}
}
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答