collections - how to remove commas from list of string values and get unique values from list -


i have list of string values. want remove duplicates it.

list<string> numbers = form.getvalues(); set<string> hs = new hashset<string>(); hs.addall(numbers ); numbers .clear(); numbers .addall(hs);  //number values -> 12342,12342, 23434,23434 

i unable unique values after converting set because has comma separated values.

it great know in first line in code. have 1 string values , comma or few strings in number list. in first case have split long string. otherwise work 1 element list ... replace first line with:

list<string> numbers = form.getvalues().split(","); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -