String contains example in java

The concat method of string returns true if and only if given string contains the specified sequence of char values.

// String contains example in java
public class StringContainsExample {
    public static void main(String[] args) {
        // declare the String with some text
        String string = "some text here";
        // To get the char at from given index.
        // You need to use String's charAt method as shown below
        boolean contains = string.contains("text");
        if (contains) {
            System.out.println("The given string contains 'text' char sequence");
        } else {
            System.out.println("The given string doesn't contains 'text' char sequence");

The output of above example will be as:

The given string contains 'text' char sequence