@@ -0,0 +1,1807 @@
+/*%0A * A linked list is similar to an array, it holds values. However, links in a linked list do not have indexes.%0A * With a linked list you do not need to predetermine it's size as it grows and shrinks as it is edited.%0A * This is an example of a singly linked list. Elements can only be added/removed at the head/front of the list.%0A*/%0Aclass LinkedList%7B%0A%09private Link head; //Head refers to the front of the list%0A%0A%09public LinkedList()%7B%0A%09%09head = null;%0A%09%7D%0A%0A%09public void insertHead(int x)%7B%09//Insert an element at the head%0A%09%09Link newLink = new Link(x); //Create a new link with a value attached to it%0A%09%09newLink.next = head; %09%09//Set the new link to point to the current head%0A%09%09head = newLink; %09%09%09//Now set the new link to be the head%0A%09%7D%0A%0A%09public Link deleteHead()%7B //Delete the element at the head%0A%09%09Link temp = head;%0A%09%09head = head.next; //Make the second element in the list the new head, the Java garbage collector will later remove the old head%0A%09%09return temp;%0A%09%7D%0A%0A%09public boolean isEmpty()%7B //Returns true if list is empty%0A%09%09return(head == null);%0A%09%7D%0A%0A%09public void display()%7B //Prints contents of the list%0A%09%09Link current = head;%0A%09%09while(current!=null)%7B%0A%09%09%09current.displayLink();%0A%09%09%09current = current.next;%0A%09%09%7D%0A%09%09System.out.println();%0A%09%7D%0A%7D%0A%0Aclass Link%7B%0A%09public int value;%0A%09public Link next; //This is what the link will point to%0A%0A%09public Link(int valuein)%7B%0A%09%09value = valuein;%0A%09%7D%0A%0A%09public void displayLink()%7B%0A%09%09System.out.print(value+%22 %22);%0A%09%7D%0A%7D%0A%0A//Example%0Apublic class SinglyLinkedList%7B%0A%09public static void main(String args%5B%5D)%7B%0A%09%09LinkedList myList = new LinkedList();%0A%0A%09%09System.out.println(myList.isEmpty()); //Will print true%0A%0A%09%09myList.insertHead(5);%0A%09%09myList.insertHead(7);%0A%09%09myList.insertHead(10);%0A%0A%09%09myList.display(); // 10(head) --%3E 7 --%3E 5%0A%0A%09%09myList.deleteHead();%0A%0A%09%09myList.display(); // 7(head) --%3E 5%0A%09%7D%0A%7D%0A

Create SinglyLinkedList.java