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) |
/* * 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); } }
contains("are") = true contains("do") = false
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:
No comments:
Post a Comment