How to check the given string is present or not in another string using contains method in java

How to check the given string is present or not  in another string using contains method in java





PROGRAM:


/*Syntax

string.contains(CharSequence);

*/

public class Contains{


    public static void main(String args[])
    {
        String s1="Hello Java";

        boolean b1=s1.contains("Java");
        System.out.println(b1);//true
        boolean b2=s1.contains("Python");
        System.out.println(b2);//false
    }
}

/*

true
false

 */




Comments

Popular posts from this blog

PROGRAM TO FIND FACTORIAL OF A NUMBER USING RECURSION

PROGRAM TO FIND THE COUNT OF PARTICULAR NUMBER IN AN ARRAY

TELEPHONE BOOK USING HASHMAP