title: This program not executing find the faulty code - Duplicate Strings in a linked list
body: <p>The actual program is removing duplicate strings by first storing the strings in linked list without using Linked list class of Java we should use only methods of String Class.</p>
  
  <p>The program is not executing please help me through get it executed.</p>
  
  <p>The problem is like this : </p>
  
  <ul>
  <li>Find and remove the duplicate strings in a linked list.</li>
  <li>Store the strings in a linked list and then traverse it to find the duplicates, delete them from the list and do the proper linking of the previous and the next element in the list.</li>
  </ul>
  
  <p><strong>NOTE:</strong> Don’t use the methods of <code>LinkedList</code> class of Java, write your own logic. Although, you can use the methods of the String class.</p>
  
  <pre><code>import java.io.*;
  import java.util.*;
  import java.text.*;
  import java.math.*;
  import java.util.regex.*;
  
  // Class name should be "Source",
  // otherwise solution won't be accepted
  public class Source {
      class Node {
          int data;
          Node next;
  
          public Node(int data) {
              this.data = data;
              this.next = null;
          }
      }
      public Node head = null;
      public Node tail = null;
  
      public void addNode(int data) {
          Node newNode = new Node(data);
          if (head == null) {
              head = newNode;
              tail = newNode;
          } else {
              tail.next = newNode;
              tail = newNode;
          }
      }
  
      public void removeDuplicate() {
          Node current = head, index = null, temp = null;
          if (head == null) {
              return;
  
          } else {
              while (current != null) {
                  temp = current;
                  index = current.next;
  
                  while (index != null) {
                      if (current.data == index.data) {
                          temp.next = index.next;
                      } else {
                          temp = index;
  
                      }
                      index = index.next;
                  }
                  current = current.next;
              }
          }
      }
      public void display() {
          Node current = head;
          if (head == null) {
              System.out.println("List is empty : ");
              return;
          }
          while (current != null) {
              System.out.println(current.data + " ");
              current = current.next;
          }
          System.out.println();
      }
  }
  public static void main(String[] args) {
      Source sList = new Source();
      Scanner in = new Scanner(System.in);
  
      int n, m;
  
      n = in.nextInt();
      m = in.nextInt();
      for (int i = 1; i &lt; m; i++) {
          sList.addNode( in.nextInt());
      }
  
      sList.display();
      sList.removeDuplicate();
      sList.display();
  }
  </code></pre>