title: Remove item from LinkedList
body: <p>Small problem i am having with a program here. I am trying to create a program that adds Words to Linked Lists within a Array depending on their hashCode, determined by my hashFunction. If they have the same value for their hashCode they get added into a Linked List. I have a small count method that counts how many times a word is in the List. It works by computing the value for their hashFunction. It then goes to that value in the array, and iterates through the LinkedList until it reaches a Null value. It has a count variable which is incremented each time it finds the word in the list. This is my code:</p>
  
  <pre><code>public class test{
  
      public static class Node&lt;T&gt;{
         public T data;
         public Node&lt;T&gt; next;
         public Node(){
  
         }
  
         public Node(T data, Node&lt;T&gt; next)
         {
            this.data = data;
            this.next = next;
         }
      }
  
      static Node[] array = new Node[512];
  
      public static void add(String word){
          int position = hashFunction(word);
          if(array[position] == null){
              array[position] = new Node(word, null);
          }else{
              Node newHead = new Node(word, array[position]);
              array[position] = newHead;
          }
      }
  
      public static void remove(String word){
          int remove = hashFunction(word);
          Node head = array[remove];
          if(head.data == word){
              head = head.next;
              System.out.println("Found");
          }else if(head.data != word){
              for(; array[remove] != null; array[remove] = array[remove].next){
                  if(array[remove].data == word){
                      array[remove] = array[remove].next;
                  }
              }
              System.out.println("Yusuf");
          }
      }
  
      public static int count(String word){
          int number = 0;
          int position = hashFunction(word);
          for(; array[position] != null; array[position] = array[position].next){
              if(array[position].data == word){
                  number++;
              }
          }
          System.out.println(number);
          return number;
      }
  
      public static int hashFunction(String a){
          int sum = 1;
              for(int i = 0; i&lt;a.length(); i++){
                  char b = a.charAt(i);
                  int value = (int) b;
                  sum *= value;
           }
           return sum % array.length;
       }
  
      public static void addthings(String word, int n){
          for(int i = 0; i&lt;n; i++){
              add(word);
          }
      }
  
      public static void main(String[] args) {
          addthings("abc", 500000);
          count("abc");
          count("abc");
          count("abc");
          count("abc");
          }
  }
  </code></pre>
  
  <p>My issue is the first time I add values in it and check how many times it occurs it works fine, but any more calls to the Count method after that returns 0 for some reason. </p>
  
  <p>I have another issue too which is my remove method isn't removing the items from the Linked List I want it too. The code iterates through the List, and when it finds the item which is meant to be removed, it removes the pointer from there and points it to the next value. This isn't working however. </p>
  
  <p>Can someone show me how to fix these two issues please?</p>
  
  <p>Thanks.</p>