{"id":89304,"date":"2024-02-29T18:00:58","date_gmt":"2024-02-29T12:30:58","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=89304"},"modified":"2024-02-29T18:00:58","modified_gmt":"2024-02-29T12:30:58","slug":"java-string-endswith-method","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/","title":{"rendered":"Java String endsWith() Method with Examples"},"content":{"rendered":"<p>The Java String endsWith() system is used to test if a string ends with a given suffix no longer. However, it returns factual. Differently, it returns false If the string ends with a given suffix. EndsWith() fashion internally uses the startsWith() system to find the end result.<\/p>\n<h2>Return Data Type of Java endsWith() Method<\/h2>\n<p>Return Data Type of endsWith() system False Character sequence supplied in \u201c suffix \u201d does not match the end sequence of the calling string True Character sequence supplied in \u201c suffix \u201d matches the end sequence of the calling string.<\/p>\n<h3>Java String endsWith() method<\/h3>\n<p>The Java String class endsWith() system tests if this string ends with a given suffix. It returns proper if this string ends with the given suffix; additional returns fake.<\/p>\n<h4>Hand<\/h4>\n<p>The syntax or hand of the EndsWith() system is as follows. Chapter.<\/p>\n<p>public boolean endsWith( String suffix)<\/p>\n<h4>Parameter<\/h4>\n<p>suffix Sequence of character<br \/>\n<strong>Returns<\/strong><br \/>\ntrue or false<\/p>\n<h4>Internal perpetration<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">public boolean endsWith( String suffix){\nreturn \nstartsWith(suffix,value.length-suffix.value.length);<\/pre>\n<p>The internal perpetration shows that the endWith() system is dependent on the startsWith() system of the String class.<\/p>\n<h3>Java String endsWith() Method<\/h3>\n<p><strong>Example<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">public class EndsWith{\npublic static void main( String args()){\nString s1 = \" TechVidvan\";\n(s1.endsWith(\" n\"));\n(s1.endsWith(\" TechVidvan\"));\n}<\/pre>\n<p><strong>Affair<\/strong><br \/>\ntrue<br \/>\ntrue<\/p>\n<h3>Java String endsWith() Method<\/h3>\n<p><strong>Example<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">public class EndsWith{\npublic static void main( String() args){\nString str = \" Drink to TechVidvan\";\n(str.endsWith(\" com\"));\nif(str.endsWith(\" TechVidvan\")){\n(\" String ends with TechVidvan\");\ndifferentlySystem.out.println(\" It doesn't end with Techvidvan\");<\/pre>\n<p><strong>Affair<\/strong><br \/>\nfalse<br \/>\nString ends with TechVidvan<\/p>\n<h3>Java String endsWith() system<\/h3>\n<p>The EndsWith() system keeps track of the case perceptivity of the current character in the string. The posterior software suggests the equal.<\/p>\n<p><strong>Example<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">public class EndsWith\n\/ main system\npublic static void main( String argvs())\n\n\nString str = \" Drink to TechVidvan\";\n\n\n\/ the result of the following display statement\n\/ shows endsWith() considers the case acuteness of\n\/ the characters of a string\n(str.endsWith(\" techvidvan\"));\/\/ false because T and t are different\n(str.endsWith(\" Tech Vidvan\"));\/\/ true because every character is same<\/pre>\n<p><strong>Affair<\/strong><br \/>\nfalse<br \/>\nTrue<\/p>\n<h3>Java String endsWith() system<\/h3>\n<p>When an empty string is surpassed in the parameter of the approach endsWith(), the fashion generally returns a true cost. The motive in the reverse of that&#8217;s that a string norway variations whilst we take an empty string to it.<\/p>\n<h3>Statement<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">String str = \" TechVidvan\"\"\";\nresults in\nstr = \" TechVidvan\";\nTherefore, we can say that any string in Java ends with an empty string(\"\").\nillustration\npublic class EndsWith\n\n\n\/ main system\npublic static void main( String argvs())\n\n\nString str = \" Drink to TechVidvan\"\"\";\n\/ prints true\n(str.endsWith(\"\"));\n\/ prints false as there's no white space after the string\n(str.endsWith(\"\"));<\/pre>\n<p><strong>Affair<\/strong><br \/>\ntrue<br \/>\nFalse<\/p>\n<h3>Conclusion<\/h3>\n<p>Java String endsWith() fashion assessments whether or not a string ends with a given suffix or no longer. However, the endsWith( String suffix) approach returns factual differently false If the string ends with a givensuffix.EndsWith( String suffix) fashion throws NullPointerException while the suffix string is null.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Java String endsWith() system is used to test if a string ends with a given suffix no longer. However, it returns factual. Differently, it returns false If the string ends with a given&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":89307,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[183],"tags":[296,5377,5378,5379,327,250,5380,5381,5382,5383],"class_list":["post-89304","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-java","tag-java-string-endswith","tag-java-string-endswith-method","tag-java-string-endswith-method-with-examples","tag-java-tutorials","tag-learn-java","tag-string-endswith","tag-string-endswith-in-java","tag-string-endswith-method","tag-string-endswith-method-in-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java String endsWith() Method with Examples - TechVidvan<\/title>\n<meta name=\"description\" content=\"Java String endsWith() method&#039;s fashion assessments whether or not a string ends with a given suffix or no longer.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java String endsWith() Method with Examples - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Java String endsWith() method&#039;s fashion assessments whether or not a string ends with a given suffix or no longer.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-02-29T12:30:58+00:00\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java String endsWith() Method with Examples - TechVidvan","description":"Java String endsWith() method's fashion assessments whether or not a string ends with a given suffix or no longer.","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:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/","og_locale":"en_US","og_type":"article","og_title":"Java String endsWith() Method with Examples - TechVidvan","og_description":"Java String endsWith() method's fashion assessments whether or not a string ends with a given suffix or no longer.","og_url":"https:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2024-02-29T12:30:58+00:00","author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Java String endsWith() Method with Examples","datePublished":"2024-02-29T12:30:58+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/"},"wordCount":322,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/#primaryimage"},"thumbnailUrl":"","keywords":["java","java string endswith()","java string endsWith() method","java string endsWith() method with examples","java tutorials","Learn Java","string endswith()","string endswith() in java","string endsWith() method","string endsWith() method in java"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/","url":"https:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/","name":"Java String endsWith() Method with Examples - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/#primaryimage"},"thumbnailUrl":"","datePublished":"2024-02-29T12:30:58+00:00","description":"Java String endsWith() method's fashion assessments whether or not a string ends with a given suffix or no longer.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/#primaryimage","url":"","contentUrl":""},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/java-string-endswith-method\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Java String endsWith() Method with Examples"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/89304","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=89304"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/89304\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=89304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=89304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=89304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}