{"id":662,"date":"2021-07-14T00:02:56","date_gmt":"2021-07-14T00:02:56","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=662"},"modified":"2021-09-17T10:15:05","modified_gmt":"2021-09-17T10:15:05","slug":"how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/java\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\/","title":{"rendered":"How to check if a string contains the sequences of characters or not using java ?"},"content":{"rendered":"<div class=\"TextHeading\">\n<div class=\"hddn\">\n<h2 id=\"how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\" class=\"color-pink\">How to check if a string contains the sequences of characters or not using java ?<\/h2>\n<\/div>\n<\/div>\n<div class=\"TextHeading\">\n<div class=\"hddn\">\n<h2 id=\"contain-method\" class=\"color-blue\">Contain() Method<\/h2>\n<\/div>\n<\/div>\n<ul>\n<li><b>java.lang.String.contains()<\/b>\u00a0method searches the sequence of characters in the given string. If sequence of char values are found in this string then print\u00a0<b>Yes<\/b>\u00a0otherwise print\u00a0<b>No<\/b>.<\/li>\n<\/ul>\n<div class=\"TextHeading\">\n<div class=\"hddn\">\n<h2 id=\"sample-code-in-java\" class=\"color-blue\">Sample Code in Java<\/h2>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-java code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-java code-embed-code\">\/ Java program to demonstrate working <br\/>\/\/ contains() method <br\/>public class Wikitechy {<br\/><br\/>    \/\/ Driver code <br\/>    public static void main(String args[]) {<br\/>        String s1 = &quot;Welcome to Wikitechy&quot;;<br\/>        if (s1.contains(&quot;kite&quot;) == true) {<br\/>            System.out.println(&quot;Yes&quot;);<br\/>        }<br\/>        \/\/ prints true <br\/>        else {<br\/>            System.out.println(&quot;No&quot;);<br\/>        }<br\/>    }<br\/>}<\/code><\/pre> <\/div>\n<div class=\"TextHeading\">\n<div class=\"hddn\">\n<h2 id=\"output\" class=\"color-blue\">Output<\/h2>\n<\/div>\n<\/div>\n<div class=\"Output\">\n<div class=\"hddn\">\n<figure class=\"highlight\">\n<pre><code class=\"hljs\" data-lang=\"\"><span class=\"nt\">Yes<\/span><\/code><\/pre>\n<\/figure>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Answer : java.lang.String.contains() method searches the sequence of characters&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4004],"tags":[195,491,360,4273,203,199,214,4277,198,363,209,205,2936,222,196,212,213,4266,4267,286,207,366,204,217,282,4023,483,15926,206,4264,4276,4271,4274,4272,4269,4268,4270,4265,4275,200,197,280,364,968],"class_list":["post-662","post","type-post","status-publish","format-standard","hentry","category-java","tag-accenture-interview-questions-and-answers","tag-applied-materials-interview-questions-and-answers","tag-atos-interview-questions-and-answers","tag-best-string-library","tag-capgemini-interview-questions-and-answers","tag-casting-networks-india-pvt-limited-interview-questions-and-answers","tag-cgi-group-inc-interview-questions-and-answers","tag-check-a-string-contains-the-sequences-of-characters","tag-chetu-interview-questions-and-answers","tag-ciena-corporation-interview-questions-and-answers","tag-collabera-technologies-interview-questions-and-answers","tag-dell-international-services-india-pvt-ltd-interview-questions-and-answers","tag-fis-global-business-solutions-india-pvt-ltd-interview-questions-and-answers","tag-flipkart-interview-questions-and-answers","tag-ibm-interview-questions-and-answers","tag-indecomm-global-services-interview-questions-and-answers","tag-infosys-technologies-interview-questions-and-answers","tag-java-string-contains","tag-javacompare-strings","tag-lt-infotech-interview-questions-and-answers","tag-mphasis-interview-questions-and-answers","tag-netapp-interview-questions-and-answers","tag-oracle-corporation-interview-questions-and-answers","tag-peoplestrong-interview-questions-and-answers","tag-persistent-systems-interview-questions-and-answers","tag-rbs-india-de-interview-questions-and-answers","tag-reliance-industries-ltd-interview-questions-and-answers","tag-remaxys-infotech-interview-questions-and-answers","tag-sap-labs-india-pvt-ltd-interview-questions-and-answers","tag-string","tag-string-class-methods","tag-string-functions","tag-string-functions-in-java-with-examples","tag-string-library","tag-string-manipulation","tag-string-match","tag-string-methods","tag-string-split","tag-strings-substring","tag-tech-mahindra-interview-questions-and-answers","tag-unitedhealth-group-interview-questions-and-answers","tag-virtusa-consulting-services-pvt-ltd-interview-questions-and-answers","tag-wells-fargo-interview-questions-and-answers","tag-wipro-infotech-interview-questions-and-answers"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to check if a string contains the sequences of characters or not - Java<\/title>\n<meta name=\"description\" content=\"How to check if a string contains the sequences of characters or not using java ? - java.lang.String.contains() method searches the sequence\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wikitechy.com\/interview-questions\/java\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to check if a string contains the sequences of characters or not - Java\" \/>\n<meta property=\"og:description\" content=\"How to check if a string contains the sequences of characters or not using java ? - java.lang.String.contains() method searches the sequence\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/java\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-14T00:02:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-17T10:15:05+00:00\" \/>\n<meta name=\"author\" content=\"Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/java\\\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/java\\\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\\\/\"},\"author\":{\"name\":\"Editor\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#\\\/schema\\\/person\\\/4d5a581fb5470d1560324bddc5e8b757\"},\"headline\":\"How to check if a string contains the sequences of characters or not using java ?\",\"datePublished\":\"2021-07-14T00:02:56+00:00\",\"dateModified\":\"2021-09-17T10:15:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/java\\\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\\\/\"},\"wordCount\":151,\"commentCount\":0,\"keywords\":[\"Accenture interview questions and answers\",\"Applied Materials interview questions and answers\",\"Atos interview questions and answers\",\"best string library\",\"Capgemini interview questions and answers\",\"CASTING NETWORKS INDIA PVT LIMITED interview questions and answers\",\"CGI Group Inc interview questions and answers\",\"check a string contains the sequences of characters\",\"Chetu interview questions and answers\",\"Ciena Corporation interview questions and answers\",\"Collabera Technologies interview questions and answers\",\"Dell International Services India Pvt Ltd interview questions and answers\",\"FIS Global Business Solutions India Pvt Ltd interview questions and answers\",\"Flipkart interview questions and answers\",\"IBM interview questions and answers\",\"Indecomm Global Services interview questions and answers\",\"Infosys Technologies interview questions and answers\",\"java string contains\",\"javacompare strings\",\"L&amp;T Infotech interview questions and answers\",\"Mphasis interview questions and answers\",\"NetApp interview questions and answers\",\"Oracle Corporation interview questions and answers\",\"PeopleStrong interview questions and answers\",\"Persistent Systems interview questions and answers\",\"RBS India De interview questions and answers\",\"Reliance Industries Ltd interview questions and answers\",\"remaxys infotech interview questions and answers\",\"SAP Labs India Pvt Ltd interview questions and answers\",\"string\",\"string class methods\",\"string functions\",\"string functions in java with examples\",\"string library\",\"string manipulation\",\"string match\",\"string methods\",\"string split\",\"strings substring\",\"Tech Mahindra interview questions and answers\",\"UnitedHealth Group interview questions and answers\",\"Virtusa Consulting Services Pvt Ltd interview questions and answers\",\"Wells Fargo interview questions and answers\",\"Wipro Infotech interview questions and answers\"],\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/java\\\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/java\\\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\\\/\",\"url\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/java\\\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\\\/\",\"name\":\"How to check if a string contains the sequences of characters or not - Java\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#website\"},\"datePublished\":\"2021-07-14T00:02:56+00:00\",\"dateModified\":\"2021-09-17T10:15:05+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#\\\/schema\\\/person\\\/4d5a581fb5470d1560324bddc5e8b757\"},\"description\":\"How to check if a string contains the sequences of characters or not using java ? - java.lang.String.contains() method searches the sequence\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/java\\\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\\\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#website\",\"url\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#\\\/schema\\\/person\\\/4d5a581fb5470d1560324bddc5e8b757\",\"name\":\"Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g\",\"caption\":\"Editor\"},\"url\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/author\\\/editor\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to check if a string contains the sequences of characters or not - Java","description":"How to check if a string contains the sequences of characters or not using java ? - java.lang.String.contains() method searches the sequence","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wikitechy.com\/interview-questions\/java\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\/","og_locale":"en_US","og_type":"article","og_title":"How to check if a string contains the sequences of characters or not - Java","og_description":"How to check if a string contains the sequences of characters or not using java ? - java.lang.String.contains() method searches the sequence","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/java\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\/","og_site_name":"Wikitechy","article_published_time":"2021-07-14T00:02:56+00:00","article_modified_time":"2021-09-17T10:15:05+00:00","author":"Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Editor","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.wikitechy.com\/interview-questions\/java\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\/#article","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/java\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\/"},"author":{"name":"Editor","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757"},"headline":"How to check if a string contains the sequences of characters or not using java ?","datePublished":"2021-07-14T00:02:56+00:00","dateModified":"2021-09-17T10:15:05+00:00","mainEntityOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/java\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\/"},"wordCount":151,"commentCount":0,"keywords":["Accenture interview questions and answers","Applied Materials interview questions and answers","Atos interview questions and answers","best string library","Capgemini interview questions and answers","CASTING NETWORKS INDIA PVT LIMITED interview questions and answers","CGI Group Inc interview questions and answers","check a string contains the sequences of characters","Chetu interview questions and answers","Ciena Corporation interview questions and answers","Collabera Technologies interview questions and answers","Dell International Services India Pvt Ltd interview questions and answers","FIS Global Business Solutions India Pvt Ltd interview questions and answers","Flipkart interview questions and answers","IBM interview questions and answers","Indecomm Global Services interview questions and answers","Infosys Technologies interview questions and answers","java string contains","javacompare strings","L&amp;T Infotech interview questions and answers","Mphasis interview questions and answers","NetApp interview questions and answers","Oracle Corporation interview questions and answers","PeopleStrong interview questions and answers","Persistent Systems interview questions and answers","RBS India De interview questions and answers","Reliance Industries Ltd interview questions and answers","remaxys infotech interview questions and answers","SAP Labs India Pvt Ltd interview questions and answers","string","string class methods","string functions","string functions in java with examples","string library","string manipulation","string match","string methods","string split","strings substring","Tech Mahindra interview questions and answers","UnitedHealth Group interview questions and answers","Virtusa Consulting Services Pvt Ltd interview questions and answers","Wells Fargo interview questions and answers","Wipro Infotech interview questions and answers"],"articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.wikitechy.com\/interview-questions\/java\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/java\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/java\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\/","name":"How to check if a string contains the sequences of characters or not - Java","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"datePublished":"2021-07-14T00:02:56+00:00","dateModified":"2021-09-17T10:15:05+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757"},"description":"How to check if a string contains the sequences of characters or not using java ? - java.lang.String.contains() method searches the sequence","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/java\/how-to-check-if-a-string-contains-the-sequences-of-characters-or-not-using-java\/"]}]},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757","name":"Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g","caption":"Editor"},"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/editor\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=662"}],"version-history":[{"count":2,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/662\/revisions"}],"predecessor-version":[{"id":3399,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/662\/revisions\/3399"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}