{"id":212,"date":"2016-05-13T05:53:00","date_gmt":"2016-05-13T05:53:00","guid":{"rendered":"http:\/\/www.java2blog.com\/?p=212"},"modified":"2023-11-25T15:05:03","modified_gmt":"2023-11-25T09:35:03","slug":"java-string-endswith-example","status":"publish","type":"post","link":"https:\/\/java2blog.com\/java-string-endswith-example\/","title":{"rendered":"Java String endsWith example"},"content":{"rendered":"<div id=\"toc_container\" class=\"toc_light_blue no_bullets\"><p class=\"toc_title\">Table of Contents<\/p><ul class=\"toc_list\"><li><a href=\"#Method_syntax\">Method syntax:<\/a><\/li><li><a href=\"#String_endsWith_Example\">String endsWith Example:<\/a><\/li><\/ul><\/div>\n<div dir=\"ltr\" style=\"text-align: left;\">String&#8217;s endWith method checks if String ends with specific suffix. It returns boolean datatype.<\/p>\n<h4 style=\"text-align: left;\"><span id=\"Method_syntax\">Method syntax:<\/span><\/h4>\n<pre name=\"code\">public boolean endsWith(String suffix)<\/pre>\n<h4 style=\"text-align: left;\"><span id=\"String_endsWith_Example\">String endsWith Example:<\/span><\/h4>\n<pre name=\"code\">package org.arpit.java2blog;\n\npublic class StringEndsWithExample {\n\n public static void main(String[] args) {\n  String str = \"java2blog\";\n\n  if (str.endsWith(\"blog\")) {\n   System.out.println(\"String ends with blog\");\n  } \n  else {\n   System.out.println(\"String does not end with blog\");\n  }\n\n  if (str.endsWith(\"BLOG\")) {\n   System.out.println(\"String ends with BLOG\");\n  } \n  else {\n   System.out.println(\"String does not end with BLOG\");\n  }\n }\n\n}\n\n<\/pre>\n<p>When you run above program, you will get below output:<\/p>\n<pre name=\"code\">String ends with blog\nString does not end with BLOG<\/pre>\n<blockquote><p>Please note that endsWith method is case sensitive as you can see in above example<\/p><\/blockquote>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Table of ContentsMethod syntax:String endsWith Example: String&#8217;s endWith method checks if String ends with specific suffix. It returns boolean datatype. Method syntax: public boolean endsWith(String suffix) String endsWith Example: package org.arpit.java2blog; public class StringEndsWithExample { public static void main(String[] args) { String str = &#8220;java2blog&#8221;; if (str.endsWith(&#8220;blog&#8221;)) { System.out.println(&#8220;String ends with blog&#8221;); } else { [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_mi_skip_tracking":false},"categories":[27],"tags":[],"_links":{"self":[{"href":"https:\/\/java2blog.com\/wp-json\/wp\/v2\/posts\/212"}],"collection":[{"href":"https:\/\/java2blog.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/java2blog.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/java2blog.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/java2blog.com\/wp-json\/wp\/v2\/comments?post=212"}],"version-history":[{"count":1,"href":"https:\/\/java2blog.com\/wp-json\/wp\/v2\/posts\/212\/revisions"}],"predecessor-version":[{"id":25848,"href":"https:\/\/java2blog.com\/wp-json\/wp\/v2\/posts\/212\/revisions\/25848"}],"wp:attachment":[{"href":"https:\/\/java2blog.com\/wp-json\/wp\/v2\/media?parent=212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java2blog.com\/wp-json\/wp\/v2\/categories?post=212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java2blog.com\/wp-json\/wp\/v2\/tags?post=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}