so i have written a code that searches for a word in a textArea. here is the code:
else if(str.equals("Find Next"))
if(ta.getText().length()!=0 && t1.getText().length()!=0)
int n = ta.getText().trim().indexOf(t1.getText().trim());
The problem is that the second argument of select needs to be the ending index of the String -- it's not a size, it's a location. The code you provided works for the beginning of the String because n is zero, so your location and your size happen to be the same. I think you can solve your problem by changing your last line to:
ta.select(n,n + t1.getText().length());
In the working case (at the beginning of the String), n = 0 so we've changed nothing. In the case that isn't working, this extra "n + " moves us to the location we need to finish at.