Removing repeated words or characters with input from user
<p>I am trying to remove duplicates from an input. There are numerous ways to do this, using ArrayList, LinkedList , Hash set etc. I know how to do this, if the input is given as say{"apple", "ball", "apple", "cat"}, specified in the problem.
But I want to use to scanner class and get input say a line and want to remove duplicates in the character, or remove duplicate words. Do you have a simple way to do this.
I have included my working code for the earlier scenario.</p>

<pre><code>public static void main(String[] args) {
        // TODO code application logic here

        Scanner scan= new Scanner(System.in);
        String[] str= {"a", "b", "c", "a"};
        System.out.println("enter text");
        List&lt;String&gt; l= 
                Arrays.asList(str);
        System.out.println(l);
        Set&lt;String&gt; set= new HashSet&lt;String&gt;(l);
        System.out.println(set);
    }
</code></pre>
