fastread homefastrread library fastread menu

Java : String contains

Tutorial by:Arena Buocel      Date: 2016-04-30 01:41:16

❰ Previous Next ❱

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.

Signature

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

  1. public boolean contains(CharSequence sequence)  

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

class ContainsExample{  

public static void main(String args[]){  

String name="what do you know about me";  

System.out.println(name.contains("do you know"));  

System.out.println(name.contains("about"));  

System.out.println(name.contains("hello"));  

}}  

true

true

false

 

❰ Previous Next ❱


Java

Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website