Hello guys maybe you maybe can help . here is my problem
For example : “I am running all over the time every time with my dog and my sister”
I want to have a list containing all the unique words from the above sentences :
List data = {I,am,running,all,over,the,time,every,with,my,dog,and,sister}
I already tried this code below but it runs slow with big sentences
List textList = new ArrayList();
StringTokenizer stringTokenizer = new StringTokenizer(text);
while (stringTokenizer.hasMoreElements()) {
String tokenData = (String) stringTokenizer.nextElement();
if ((textList.size() > 0)) {
Boolean exist = false;
for (int i = 0; i < textList.size(); i++) {
if (tokenData.toLowerCase().equals(
textList.get(i).toString().toLowerCase()))
exist = true;
}
if (exist == false)
textList.add(tokenData);
} else {
textList.add(tokenData);
}
}
Is there anyway other than this faster way but same result . I appreciate your reply thx
try this code
Set only allows unique values and will ignore duplicates.