for example:
String input = "AAAA AAAA BBBB BBBB CCCC djgu";
the result should be: {AAAA, BBBB, digu, CCCC}
Nah source code yang saya gunakan adalah sebagai berikut:
String s2 = "cahdt aaaa aaaa bbbbb ddddd";
List li = new ArrayList ();
StringTokenizer st = new StringTokenizer (s2 ,";&@! - ");
while (st.hasMoreTokens ()) {
String temp = st.nextToken ();
li.add (temp);
}
Set set2 = new HashSet(li);
String [] result2 = new String [set2.size ()];
set2.toArray (result2);
for (String s: result2) {
System.out.print (s + ",");
}
No comments:
Post a Comment