public class Test { public static void main(String[] args) { String a = "SN1,SN1,SN2,SN1 "; String[] ss = a.split(","); Set set = new HashSet<String>(); for (String s : ss) { set.add(s.trim()); } for (Iterator it = set.iterator(); it.hasNext();) { System.out.println(it.next()); } } }
public class Test {
public static void main(String[] args) {
String a = "SN1,SN1,SN2,SN1 ";
String[] ss = a.split(",");
Set set = new HashSet<String>();
for (String s : ss) {
set.add(s.trim());
}
for (Iterator it = set.iterator(); it.hasNext();) {
System.out.println(it.next());
}
}
}