how to get index of second occurrence java

Solutions on MaxInterview for how to get index of second occurrence java by the best coders in the world

showing results for - "how to get index of second occurrence java"
Anton
07 May 2018
1String str = "itiswhatitis";
2//returns the index of the first i in "is"
3str.indexOf("is");
4//returns the index of the second occurence of  i in "is" after the first 
5str.indexOf("is", str.indexOf("is") + 1);
6