Javatpoint Logo
Javatpoint Logo

Java String contains()

The java string contains() method searches the sequence of characters in this string. It returns true if sequence of char values are found in this string otherwise returns false.


Internal implementation

Signature

The signature of string contains() method is given below:


Parameter

sequence : specifies the sequence of characters to be searched.


Returns

true if sequence of char value exists, otherwise false.


Throws

NullPointerException : if sequence is null.


Java String contains() method example

Test it Now
true
true
false

Java String contains() Method Example 2

The contains() method searches case sensitive char sequence. If the argument is not case sensitive, it returns false. Let's see an example below.

true
false

Java String contains() Method Example 3

The contains() method is helpful to find a char-sequence in the string. We can use it in control structure to produce search based result. Let us see an example below.

Output:

This string contains javatpoint.com




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA