diff --git "a/\344\275\234\344\270\232/LinkList.class" "b/\344\275\234\344\270\232/LinkList.class" new file mode 100644 index 0000000000000000000000000000000000000000..11daf0b86988d65528fffe9019e5b37d90010bb2 Binary files /dev/null and "b/\344\275\234\344\270\232/LinkList.class" differ diff --git "a/\344\275\234\344\270\232/LinkList.java" "b/\344\275\234\344\270\232/LinkList.java" new file mode 100644 index 0000000000000000000000000000000000000000..1e9c7c2b48a5062c5436ab8825df65c2268f66de --- /dev/null +++ "b/\344\275\234\344\270\232/LinkList.java" @@ -0,0 +1,41 @@ +public class LinkList { + + private Node head; + + public void addToRear(Object data){ + Node node = new Node(data); + Node head = this.head; + while (true){ + if (head.getNext()==null){ + head.setNext(node); + return; + } + } + } + + public void addToFront(Object data){ + Node node = new Node(data); + node.setNext(this.head); + this.head = node; + return; + } + public void removeItem(Object object){ + Node head = this.head; + if (head.getData().equals(object)){ + this.head = head.getNext(); + return; + } + while (true){ + if (head.getNext().getData().equals(object)){ + head.setNext(head.getNext().getNext()); + return; + } + head = head.getNext(); + } + } + + public LinkList(Object data) { + this.head = new Node(data); + } + +} diff --git "a/\344\275\234\344\270\232/Node.class" "b/\344\275\234\344\270\232/Node.class" new file mode 100644 index 0000000000000000000000000000000000000000..011e57148cdd2da1bd0ae53ffc808580e82be4b8 Binary files /dev/null and "b/\344\275\234\344\270\232/Node.class" differ diff --git "a/\344\275\234\344\270\232/Node.java" "b/\344\275\234\344\270\232/Node.java" new file mode 100644 index 0000000000000000000000000000000000000000..d0268e7f4f877401f8d69900cea1f8048fcc1944 --- /dev/null +++ "b/\344\275\234\344\270\232/Node.java" @@ -0,0 +1,30 @@ +public class Node { + private Object data; + private Node next; + + public Object getData() { + return data; + } + + public void setData(Object data) { + this.data = data; + } + + public Node getNext() { + return next; + } + + public void setNext(Node next) { + this.next = next; + } + + public Node(Object data) { + this.data = data; + } + + public Node(Object data, Node next) { + this.data = data; + this.next = next; + } + +} diff --git "a/\344\275\234\344\270\232/TryToRun.class" "b/\344\275\234\344\270\232/TryToRun.class" new file mode 100644 index 0000000000000000000000000000000000000000..c818e9d108b0646c9f8c03cdb7f86277477c2810 Binary files /dev/null and "b/\344\275\234\344\270\232/TryToRun.class" differ diff --git "a/\344\275\234\344\270\232/TryToRun.java" "b/\344\275\234\344\270\232/TryToRun.java" new file mode 100644 index 0000000000000000000000000000000000000000..8f2ea38718deac6a1b044f047c77ae9a8f7947cc --- /dev/null +++ "b/\344\275\234\344\270\232/TryToRun.java" @@ -0,0 +1,9 @@ + +public class TryToRun { + public static void main(String[] args) { + LinkList linkList = new LinkList("a"); + linkList.addToRear("b"); + linkList.addToFront("c"); + linkList.removeItem("a"); + } +}