@@ -0,0 +1,2022 @@
+/**%0A * Company%0A * Copyright (C) 2014-2017 All Rights Reserved.%0A */%0Apackage com.cwenao.datastructure;%0A%0A/**%0A * @author cwenao%0A * @version $Id LinkedLists.java, v 0.1 2017-07-10 8:15 cwenao Exp $$%0A */%0Apublic class LinkedLists %7B%0A%0A    class Node %7B%0A        Node next = null;%0A        int data;%0A%0A        public Node(int data) %7B%0A            this.data = data;%0A        %7D%0A%0A    %7D%0A%0A    private Node head = null;%0A%0A    public void addNode(int data) %7B%0A        Node currentNode = new Node(data);%0A        if (head == null) %7B%0A            head = currentNode;%0A            return;%0A        %7D%0A%0A        Node nextNode = head;%0A        while (nextNode.next != null) %7B%0A            nextNode = nextNode.next;%0A        %7D%0A        nextNode.next = currentNode;%0A%0A    %7D%0A%0A    public int size() %7B%0A        int len = 0;%0A        if (head == null) %7B%0A            return len;%0A        %7D%0A        len = 1;%0A        Node nextNode = head;%0A%0A        while (nextNode.next != null) %7B%0A            nextNode = nextNode.next;%0A            len++;%0A        %7D%0A        return len;%0A%0A    %7D%0A%0A    public boolean removeNode(int index) %7B%0A        if (index %3C 0 && index %3E size()) %7B%0A            return Boolean.FALSE;%0A        %7D%0A%0A        Node currentNode = node(index);%0A        Node preNode = null;%0A%0A        if (index == 0) %7B%0A            head = currentNode;%0A        %7D else %7B%0A            preNode = node(index - 1);%0A            preNode.next = currentNode.next;%0A            currentNode.next = null;%0A        %7D%0A%0A        return Boolean.TRUE;%0A    %7D%0A%0A    Node node(int index) %7B%0A        Node nextNode = head;%0A        for (int i=0;i%3Cindex;i++) %7B%0A            nextNode = nextNode.next;%0A        %7D%0A        return nextNode;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        LinkedLists linkedLists = new LinkedLists();%0A        System.out.println(linkedLists.size());%0A        linkedLists.addNode(1);%0A        linkedLists.addNode(2);%0A        linkedLists.addNode(3);%0A%0A        System.out.println(linkedLists.size());%0A        linkedLists.removeNode(2);%0A        System.out.println(linkedLists.size());%0A    %7D%0A%7D%0A%0A

add the linkedlists with simple implements