title: How to remove duplicate words containing in ArrayList<String> in java
body: <p><strong>I have used the below code:</strong> </p>
  
  <p>The output should be each word within the string in the ArrayList occurring only once.</p>
  
  <p><strong>O/P:</strong> </p>
  
  <p>"This is a list and Arraylist with set". Any suggestion will be appreciated. </p>
  
  <pre><code>public class ArrayListTest {
  
  public static void main(String[] args) {
      String s1="This is a list";
      String s2="This is a list and Arraylist";
      String s3="and Arraylist with set";
  
      ArrayList&lt;String&gt; al = new ArrayList&lt;String&gt;();
      al.add(s1);
      al.add(s2);
      al.add(s3);
  
  
          System.out.println(al);
          LinkedHashSet&lt;String&gt; lhs = new LinkedHashSet&lt;String&gt;();
          lhs.addAll(al);
          System.out.println(lhs);
  
  
  
      }
  
  }
  </code></pre>