Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SF5
- {
- public static void main(String[] args)
- {
- LL list = new LL();
- list.addFirst(1);
- System.out.println(list.removeFirst());
- }
- }
- class LL
- {
- private class Node
- {
- private Node link;
- private int x;
- public Node(int x)
- {
- this.x = x;
- }
- }
- private Node first = null;
- private Node last = null;
- public void addFirst(int d)
- {
- Node newNode = new Node(d);
- newNode.link = first;
- first = newNode;
- }
- public Node removeFirst()
- {
- Node p;
- p = first;
- if (p == null)
- return p;
- else
- {
- first = first.link;
- return p;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement