Hi all;
I have a problem regarding my loop.The code is below:
StringTokenizer wordFactory = new StringTokenizer(myNewString);
while (wordFactory.hasMoreTokens())
{
//get the next word from the sentence
Aword = wordFactory.nextToken();
long time = System.currentTimeMillis();
}
let me explain how the code works.
the input is "aaa bbb ccc" and it is suppose to print one by one and the output will be printed out one by one, aaa then bbb and then ccc.
i do this method since i want to track the time of each word with brute force method :
for(char r = 'a'; r <= 'z'; r++){
first = r;
for(char s = 'a'; s<='z'; s++){
second = s;
for (char t = 'a'; t <= 'z'; t++){
third = t;
anotherWord=String.valueOf(first)+second+third;
if(anotherWord == Aword){
System.out.print(anotherWord)
//track the time when anotherWord == Aword
}
}
}
}
my problem is, once "aaa" has been detected by the code, how can i proceed to detect "bbb" and "ccc"?
i really appreciate anyone's help. if the problem explanation is quite blur, u can ask me to explain in detail!
thanx in advance!
regards;
dulcinea


Reply With Quote


Bookmarks