Online Java Compiler By
JavaTpoint.com
public class IndexOfExample2 { public static void main(String[] args) { String s1 = "This is indexOf method"; // Passing Substring int index = s1.indexOf("method"); //Returns the index of this substring System.out.println("index of substring "+index); } }
Output