Java String.contains() Method Example

The String.contains(CharSequence s) method returns true if and only if this string contains the specified sequence of char values.

Java String.contains() Method Example

public class ContainsExample {
    public static void main(String[] args) {
        String str = "javaguides";
        boolean contains = str.contains("guides");
        System.out.println("Contains : " + contains);
    }
}

Output:
Contains: true 

Reference


Comments