I have to String objects:
String first = \"/Some object that has a loop in it object/\"; String second = \"object\";
What I need to do is find
try like below...
String str = "/Some object that has a loop in it object/"; String findStr = "object"; int lastIndex = 0; int count =0; while(lastIndex != -1){ lastIndex = str.indexOf(findStr,lastIndex); if( lastIndex != -1){ count ++; lastIndex+=findStr.length(); } } System.out.println(count);