I was trying to execute the following program for seaching a pattern in the string.
I was expecting the answer as a tokenfound : tokenfound : tokenfound :45 tokenfound : tokenfound : tokenfound :
but it is looping infinitely?
~Sanjeev Singh<br />SCJP 1.5
posted 9 years ago
I think the problem is that the pattern can be matched by the empty string (which has length 0). If the scanner advances by 0 characters, it will never get beyond the start of the string, and thus finds the same (empty) string over and over.