i want to count number of times "dog" appears on a sentence but my code its creating a loop
how can i stop this loop??
how can i stop this loop??
println(input); int index = -1; int count = 0; print("Counting dogs:"); do{ index = input.indexof("dog"); // the loop starts here if(index != -1){ count++; print(count+" "); } }while(index != -1); println("The word \"dog\" appears "+count+" times."); } }