The contains method is used to check if a string contains another string.

    
    String greeting = "Hello";

    boolean greetingContains = greeting.contains("He");

    System.out.println(greetingContains);
    // true