Worked example
String w = "programming";
System.out.println(w.indexOf("gram")); // 3
System.out.println(w.indexOf("m")); // 6 — the FIRST m
System.out.println(w.indexOf("z")); // -1 — not found
Combined with substring this becomes useful: find where something starts, then cut from there.