Strings In Depth7 / 18
Up next

Search a string

class Main {
    public static void main(String[] args) {
        String s = "hello world";
        System.out.println(s.contains("world"));
        // indexOf returns the position, or -1
        System.out.println(s.indexOf("o"));
        System.out.println(s.startsWith("hello"));
        System.out.println(s.endsWith("!"));
    }
}
What you're solving

contains, indexOf, startsWith, endsWith