Java String: contains() Method
contains() method - Checks whether a string contains another string
The contains() method is used to check if and only if a string contains the specified sequence of character values.
Pictorial presentation of Java String contains() Method
Java Platform: Java SE 8 and above
Syntax contains() method
contains(CharSequence s)
Parameters contains() method
Name | Description | Type |
---|---|---|
s | The sequence to search for. | String |
Return Value contains() method:
- Returns true if the string contains the specified sequence of character values
- False otherwise.
Return Value Type: boolean
Example: Java String contains() Method
Output:
Original String: Java Exercises and SQL Exercises Specified sequence of char values: and true
Java Code Editor:
Previous:concat Method
Next:contentEquals Method
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics