How to get rid of duplicate entries in a comma separated string in java?
<p>I have a string places="city,city,town". I need to get "city,town". Basically get rid of duplicate entries in the comma separated string.</p>

<p>places.split(","); will give me array of String. I wonder, if I can pass this array to a HashSet or something, which will automatically get rid of duplicates, but trying something like: </p>

<pre><code>HashSet test=new HashSet(a.split(","));
</code></pre>

<p>gives the error:</p>

<pre><code>cannot find symbol
symbol : constructor HashSet(java.lang.String[])
</code></pre>

<p>Any neat way of achieving this, preferably with least amount of code?</p>
