Wednesday, 16 March 2016

Java Tutorial : Java String (contains(CharSequence s) method)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=opWttGwhLoE&list=UUhwKlOVR041tngjerWxVccw

 Click the below Image to Enlarge
Java Tutorial : Java String (contains(CharSequence s) method) 
ContainsDemo.java
/*
 * public boolean contains(CharSequence s)
 * 
 * Parameters: 
 * ----------  
 * s - the sequence to search for.
 * 
 * Returns: 
 * ------- 
 * Returns true if and only if this string contains
 * the specified sequence of char values.
 */

public class ContainsDemo
{

    public static void main(String[] args)
    {
        String str = "How are you peter?";

        boolean isExist = str.contains("are");
        System.out.println("contains(\"are\") =  " + isExist);

        /*
         * CharSequence is an interface that is implemented
         * by the String class. Therefore, you can use a
         * string as an argument for the contains() method.
         */

        isExist = str.contains("do");
        System.out.println("contains(\"do\")  =  " + isExist);

    }
}
Output
contains("are") =  true
contains("do")  =  false
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/StringDemo_Contains_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/StringDemo_Contains_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/627e98cff1455d9113a0f59150e05649fae86225/BasicJava/StringDemo_Contains_App/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment