• Post Reply Bookmark Topic Watch Topic
  • New Topic

My bad logic or it was just misunderstanding  RSS feed

 
Pakawat Gibson LP
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a String generator that generates sequence of chars and I show it as a String on user screen. When it recieves more chars, that String grows bigger and bigger. My task is to iterate check that the growing recieved chars match up some String.

while(!stringGenerator.getString().endsWith(stringToMatch) {
;
}
// get out of while loop and doSomething

and this geranates the nasty problem of forever loops and misfiring the command when it is supposed to be matched.

let the while loop run isn't fast enough to detect with endsWith() method?

I'm going to die.

Thanks a lot for your coming helps.

the while loop

[ September 26, 2008: Message edited by: Pakawat Gibson LP ]
[ September 26, 2008: Message edited by: Pakawat Gibson LP ]
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's hard to say what might be going wrong without knowing what the strings are, or what the code really is supposed to be doing, but are you saying that sometimes stringGenerator.getString() returns something that ends with stringToMatch, and yet the loop is not being terminated? (Keep in mind that endsWith is case-sensitive.)

Can you post a shortest possible code example that exhibits this behavior? Trying to find such an example is usually a good way to spot a bug.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!