Java debugging on CodeHS -


i need debugging this; problems on lines 10-13. says can't convert string int, don't know how fix it. code looks word "bug" within given strings.

        public class bughunter extends consoleprogram {     public void run()     {         string test1 = "debug";         string test2 = "bugs bunny";         string test3 = "boogie";         string test4 = "baby buggie";         int index1 = findbug(test1);         int index2 = findbug(test2);         int index3 = findbug(test3);         int index4 = findbug(test4);          printbug(test1, index1);         printbug(test2, index2);         printbug(test3, index3);         printbug(test4, index4);     }      // returns index of string "bug" inside string str     // if str not contain string "bug", returns -1     public string findbug(string str)     {         str.indexof("bug");     }      public void printbug(string test, int index)     {         if(index != -1)         {             system.out.println(test + " has bug @ index " + index);         }         else         {             system.out.println(test + " has no bugs");         }     } } 

it appears findbug supposed return index of word bug int. should like

public int findbug(string str) {     return str.indexof("bug"); } 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -