title: Deleting a specified `Link` from `LinkedList`
body: <p>folks, I'm having trouble with removing a specified <code>Link</code> from a <code>LinkedList</code>. For example, if I have:</p>
  
  <pre><code>"A" --&gt; "B" --&gt; "C"
  </code></pre>
  
  <p>and would like to remove a <code>Link</code> <code>"B"</code>, so the result would be:</p>
  
  <pre><code>"A" --&gt; "C"
  </code></pre>
  
  <p>I'm having troubles with how to get the previous <code>Link</code> <code>"A"</code> and reference to <code>"C"</code>. Can anyone help me out with that? The method is:</p>
  
  <pre><code> public void delete(String data){
          if(isEmpty()){
              System.out.println("The list is empty!");
              System.exit(0);
          }
          else{
              Link current = firstLink;
              Link previous = firstLink;
              while(current != null){
                  if(current.getData().equals(data)){
                      previous = current.getNext();   
                  }
                  else{
                      previous = current;
                      current = current.getNext();
                  }
              }
          }
      }
  </code></pre>
  
  <p>Class <code>Link</code></p>
  
  <pre><code>package LinkedList;
  
  public class Link{
  
      private String data;
      private Link next;
  
      public Link(String data){
          this.data = data;
      }
  
      public void display(){
          System.out.println(data);
      }
  
      public String getData(){
          return this.data;
      }
  
      public Link getNext(){
          return this.next;
      }
  }
  
  class LinkedList{
  
      private Link firstLink;
  
      public LinkedList(){
          this.firstLink = null;
      }
  
      public boolean isEmpty(){
          return (this.firstLink == null);
      }
  
      public void insert(String data){
          Link newLink = new Link(data);
          Link newLinkNext = newLink.getNext();
          newLinkNext = firstLink;
          firstLink = newLink;
      }
  
      public Link deleteFirst(){
          if(isEmpty()){
              return null;
          }
          else {
              Link deletedOne = this.firstLink;
              Link nextLink = firstLink.getNext();
              firstLink = nextLink;
              return deletedOne;
          }
      }
  
      public void delete(String data){
      if(isEmpty()){
          System.out.println("The list is empty!");
          System.exit(0);
      }
      else{
          Link current = firstLink;
          Link previous = firstLink;
          while(current != null){
              if(current.getData().equals(data)){
                  previous = current.getNext();   
              }
              else{
                  previous = current;
                  current = current.getNext();
              }
          }
      }
  }
  </code></pre>