Why is it that after the first method is executed in the main method, the rest of the code is not executed?

package chap05;

public class StringFindTest {


public static void testFind(String str, String substr) {
    
    int count = 0;
    int pos = 0;
    
    do{
        if(str.indexOf(substr, pos) >= 0){
            
            countPP;
            System.out.println(""+count+":"+str.indexOf(substr, pos));
            pos = str.indexOf(substr, pos) + substr.length() - 1;
        }
        
    }while(pos >= 0);
    
}

public static void main(String[] args) {
    
    //StringFindTest test = new StringFindTest();
    String str = "AAA01234AA01234aa012340aAA01234Aa01234aa";
    String substr = "AA";
    //
    testFind(str.toUpperCase(), substr.toUpperCase());
    //
    testFind(str, substr);
}

}

< H2 > run results < / H2 > The first occurrence position of the

substring is: the second occurrence position of the 0
substring is: 1 the third occurrence position of the
substring is: the fourth occurrence position of the 8
substring is: the 5th occurrence position of the 15
substring is: 23
the 6th occurrence position of the substring is: 24
the 7th occurrence position of the substring is: 31
the 8th occurrence position of the substring is: 38

< hr >

as above, why?

Mar.04,2021

just jump out of the do..while loop, otherwise if (str.indexOf (substr, pos) > = 0) and while (pos > = 0) keep redoing.
add an else {break;};

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b39d74-2c1e1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b39d74-2c1e1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?