Maybe tomorrow the light will come on.
Type: Posts; User: Norm
Maybe tomorrow the light will come on.
I used the word column as if the String were a row made up of columns. The first column is the first position in the String at index=0.
Since the code needs to continue looking for a letter until it is not found, code would need a loop.
You could use a 0 for the starting column for the indexOf() search for the first search.
Something like this:
find first one and save the column: int ix = str.indexOf("a")
look for the next one starting at that saved column+1
int ix2 = str.indexOf("a", ix+1);
You need to save the last value returned by indexOf to use in the next search.
If you find the first "a" at 1, then start the next search for an "a" at 2
There is another version of the indexOf() method that will start its search at another column besides column 0.
Use that version with the column past where the last match was found. If found at 8...