contains() - String Methods in Java
This article is a part of String Methods in Java.
The contains() method checks if the specified sequence of characters is present
in the string or not. The parameter passed in this method is of String type.
Return type
The return type for contains() method is of Boolean type. It returns true
if the specified
sequence of characters is present in the string, false otherwise.
Let us look at an example code.
Example
Output
Let us look at the output of the above example code.
Since, “Learn” is a part of the string “LearningJournal,” it returns the value true in the output console. However, “Learner” isn`t a part of the string “LearningJournal,” it returns the value false in the output console.