title: Finding the right place and storing in LinkedList
body: <p>I am trying to store the strings in a LinkedList. I am not allowed to pre-sort, but find the place and pass the string to the linked list. When i pass the strings through text file, the string do not go through the last else condition.
  My input file has 
  joe
  appy
  appz
  zebra
  cat</p>
  
  <p>When it reaches appz, it doesn't go through any statement. It is supposed to insert the last else condition and print 5, but doesn't do that.</p>
  
  <pre><code>/**
       * Gets the string and arranges them in order
       * @param newString
       */
      public void store(String newString) {
  
          LinkedListNode current = head;
          System.out.println(newString);
  
          // if no element in the list
          if (current==null){
              System.out.println("1");
              makeNode(newString);
          }
  
          // if only 1 elements in the list
          else if(current.getNext()==null ){
              System.out.println("2");
              if(newString.compareTo(current.getName())&lt;0){
                  insertBefore(current.getName(),newString);
              } else{
                  insertAfter(current.getName(),newString);
              }
          }
  
          // if the element is smaller than the head in the list
          else if(newString.compareTo(current.getName()) &lt; 0){
              System.out.println("3");
              LinkedListNode temp = makeNode(newString);
              temp.setNext(current);
              head=temp;
          }
  
          // if the element is greater than the tail in the list
          else if(newString.compareTo(findTail().getName()) &gt; 0){
              System.out.println("4");
              insertAfter(findTail().getName(),newString);
          }
  
          // for more than two elements in the list
          else{
              System.out.println("5");
              while(!(newString.compareTo(current.getName())&gt;0  &amp;&amp; newString.compareTo(current.getNext().getName())&lt;0 ) &amp;&amp; current.getNext()!=null){
                  current=current.getNext();
              }
  
              if(newString.compareTo(current.getName())&lt;0){
                  insertBefore(current.getName(),newString);
              }
              else{
                  insertAfter(current.getName(),newString);
              }
          }
  
      }   // end of store()
  </code></pre>