Here is my class program. It is an ordered linked list and I am having trouble with 1) the add and 2) find methods, as well as 3) how to use the String.compareToIgnoreCase method to put the nodes in the linked list in order of increasing key value. Please help.
public class LinkedList<T>{ protected Node<T> head; protected int size; public LinkedList(){ head = null; size = 0; } private class Node<T>{ private String key; private Node<T> next; private T value; private Node(String index){ key = index; next = null; value = null; } private Node(String index, T value2) { key = index; next = null; value = value2; } private Node(String index, Node<T> reference, T value2) { key = index; next = reference; value = value2; } } //adds new node to the list. k stand for key, and v stands for value. //For some reason, it only adds the head and the tail of the linked list. What is in the middle returns null. What should be done so the middle of the list is included? public T add(String k, T v){ if(head == null){ head = new Node<T>(k, v); size++; return null; } Node<T> node; for(node = head; node.next != null && node.k.compareToIgnoreCase(k) < 0; node = node.next){ node.next = new Node<T>(k, v); node = node.next; size++; return node.value; } while(node != null){ node.next = new Node<T>(k, v); node = node.next; size++; return node.value; } return node.value; } //Method for finding certain nodes. //It only finds the head node. Anything else returns null. //What should be done so that it can find the rest of the list? public T find(String k){ Node<T> node = new Node<T>(k); if(!k.equalsIgnoreCase(head.key) && !k.equalsIgnoreCase(node.key)){ return null; } else{ if(k.equalsIgnoreCase(head.key)){ return head.value; } else{ if(k.equalsIgnoreCase(node.key)){ return node.value; } else{ return node.value; } } } }