{"id":25535906,"date":"2022-07-31T02:25:25","date_gmt":"2022-07-30T20:55:25","guid":{"rendered":"https:\/\/entri.app\/blog\/?p=25535906"},"modified":"2022-11-23T15:04:58","modified_gmt":"2022-11-23T09:34:58","slug":"all-you-should-know-about-substring-in-java","status":"publish","type":"post","link":"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/","title":{"rendered":"All You Should Know About Substring in Java"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69e6dc340bf99\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69e6dc340bf99\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#What_is_a_Substring_in_Java\" >What is a Substring in Java?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#Methods_to_Get_a_Substring\" >Methods to Get a Substring<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#Use_and_Applications_of_Substring\" >Use and Applications of Substring<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#Explain_the_variants_of_the_substring_method\" >Explain the variants of the substring() method.<\/a><\/li><\/ul><\/nav><\/div>\n<div class=\"detail-banner article-banner-details banner-height\">\n<div class=\"article-info test-class\">\n<h1><\/h1>\n<\/div>\n<\/div>\n<div class=\"info-details\">\n<div id=\"articleLongDescription\">\n<article class=\"desig_author empty-text\">A substring is a subset or part of another string, or it is a contiguous sequence of characters within a string. For example, &#8220;Substring&#8221; is a substring of &#8220;Substring in Java.&#8221;<\/article>\n<article class=\"desig_author empty-text\">\n<article>\n<h2><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-25520910 size-full\" src=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square.png\" alt=\"Python and Machine Learning Square\" width=\"345\" height=\"345\" srcset=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square.png 345w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-300x300.png 300w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-150x150.png 150w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-24x24.png 24w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-48x48.png 48w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-96x96.png 96w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-75x75.png 75w\" sizes=\"auto, (max-width: 345px) 100vw, 345px\" \/><\/a><\/h2>\n<h2 id=\"what_is_a_substring_in_java\"><span class=\"ez-toc-section\" id=\"What_is_a_Substring_in_Java\"><\/span><strong>What is a Substring in Java?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Substring in Java is a commonly used method of java.lang.String class that is used to create smaller strings from the bigger one. As strings are permanent in Java, the original string remains as it is, and the method returns a new string.<\/p>\n<h3><strong>Syntax:<\/strong><\/h3>\n<p>string.substring(int startIndex, int endIndex)<\/p>\n<p>Note: Here, the endIndex is exclusive, but the startindex is inclusive, and the string is an\u00a0object\u00a0of the String class. We will see the use more in detail below.<\/p>\n<p>The method produces an IndexOutofBoundsException if:<\/p>\n<ol>\n<li>endIndex is less than startIndex<\/li>\n<li>endIndex\/StartIndex is greater than the string&#8217;s length<\/li>\n<li>endIndex\/StartIndex is negative<\/li>\n<\/ol>\n<p style=\"text-align: center;\"><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\"><strong>Learn to code from industry experts! Enroll here<\/strong><\/a><\/p>\n<div class=\"engagingBanner\"><\/div>\n<\/article>\n<article>\n<h2 id=\"methods_to_get_a_substring\"><span class=\"ez-toc-section\" id=\"Methods_to_Get_a_Substring\"><\/span><strong>Methods to Get a Substring<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Substring in Java can be obtained from a given string object using one of the two variants:<\/p>\n<h3><strong>1. Public String substring(int startIndex)<\/strong><\/h3>\n<p>This method gives a new String object that includes the given string&#8217;s substring from a specified inclusive startIndex.<\/p>\n<p>Syntax: public String substring(int startIndex)<\/p>\n<p>Parameters: startIndex- the starting index (inclusive)<\/p>\n<p>Returns: Specified substring<\/p>\n<h4>Example:<\/h4>\n<p>Code: public class TestSubstring {<\/p>\n<p>public static void main(String args[])<\/p>\n<p>{<\/p>\n<p>\/\/ Initializing the String<\/p>\n<p>String Str = new String(&#8220;Substring in Java Tutorial&#8221;);<\/p>\n<p>\/\/ using substring() to extract substring<\/p>\n<p>\/\/\u00a0 should return: in Java Tutorial<\/p>\n<p>System.out.print(&#8220;The extracted substring is : &#8220;);<\/p>\n<p>System.out.println(Str.substring(10));<\/p>\n<p>} }<\/p>\n<h4>Output:<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"blend-mode\" src=\"https:\/\/www.simplilearn.com\/ice9\/free_resources_article_thumb\/startIndex.png\" alt=\"startIndex\" width=\"512\" height=\"357\" \/><\/p>\n<h3><strong>2. Public String substring(int startIndex, int endIndex):<\/strong><\/h3>\n<p>This method is used to return a new String object that includes a substring of the given string with their indexes lying between startIndex and endIndex. If the second argument is given, the substring begins with the element at the startIndex to endIndex -1.<\/p>\n<p>Syntax : public String substring(int startIndex, int endIndex)<\/p>\n<p>Parameters: startIndex: \u00a0the starting index, inclusive<\/p>\n<p>endIndex: \u00a0the ending index, exclusive.<\/p>\n<p>Return Value: Specified substring.<\/p>\n<h4>Example:<\/h4>\n<p>Code: public class TestSubstring {<\/p>\n<p>public static void main(String args[])<\/p>\n<p>{<\/p>\n<p>\/\/ Initializing the String<\/p>\n<p>String Str = new String(&#8220;Substring in Java Tutorial&#8221;);<\/p>\n<p>\/\/ using substring() to extract substring<\/p>\n<p>\/\/ should return Java<\/p>\n<p>System.out.print(&#8220;The extracted substring\u00a0 is : &#8220;);<\/p>\n<p>System.out.println(Str.substring(13, 17));<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<h4>Output:<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"blend-mode\" src=\"https:\/\/www.simplilearn.com\/ice9\/free_resources_article_thumb\/endIndex.png\" alt=\"endIndex\" width=\"642\" height=\"448\" \/><\/p>\n<\/article>\n<article>\n<h2 id=\"use_and_applications_of_substring\"><span class=\"ez-toc-section\" id=\"Use_and_Applications_of_Substring\"><\/span><strong>Use and Applications of Substring<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>1. The substring in\u00a0Java method\u00a0is used in many applications, including suffix and prefix extraction. For instance, if you want to extract the last name from a given name or extract the digits after the decimal point from a string containing digits both before and after the point. Here is the demonstration:<\/p>\n<p>Code:<\/p>\n<table>\n<tbody>\n<tr>\n<td>\/\/ Java code to demonstrate the application of substring method<\/p>\n<p>public class TestSubstring {<\/p>\n<p>public static void main(String args[])<\/p>\n<p>{<\/p>\n<p>\/\/ Initializing the String<\/p>\n<p>String Str = new String(&#8220;Rs 1500&#8221;);<\/p>\n<p>\/\/ Printing the original string<\/p>\n<p>System.out.print(&#8220;The original string\u00a0 is : &#8220;);<\/p>\n<p>System.out.println(Str);<\/p>\n<p>\/\/ using substring method to extract substring<\/p>\n<p>\/\/ returns 1500<\/p>\n<p>System.out.print(&#8220;The extracted substring\u00a0 is : &#8220;);<\/p>\n<p>System.out.println(Str.substring(3));<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<h4>Output:<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"blend-mode\" src=\"https:\/\/www.simplilearn.com\/ice9\/free_resources_article_thumb\/suffixandprefix%20.png\" alt=\"suffixandprefix%20\" width=\"641\" height=\"448\" \/><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\">Learn Coding in your Language! Enroll Here!<\/a><\/strong><\/p>\n<p>2. Check palindrome- We can use the substring in Java method to check if the given string is palindrome or not, i.e. if its read the same way from both ends. Here\u2019s the demonstration:<\/p>\n<p>Code- public class TestSubstring {<\/p>\n<p>public static void main(String[] args) {<\/p>\n<p>System.out.println(checkPalindrome(&#8220;adeda&#8221;));<\/p>\n<p>System.out.println(checkPalindrome(&#8220;ABba&#8221;));<\/p>\n<p>System.out.println(checkPalindrome(&#8220;1234321&#8221;));<\/p>\n<p>System.out.println(checkPalindrome(&#8220;AAAA&#8221;));<\/p>\n<p>}<\/p>\n<p>private static boolean checkPalindrome(String s) {<\/p>\n<p>if (s == null)<\/p>\n<p>return false;<\/p>\n<p>if (s.length() &lt;= 1) {<\/p>\n<p>return true;<\/p>\n<p>}<\/p>\n<p>String first = s.substring(0, 1);<\/p>\n<p>String last = s.substring(s.length() &#8211; 1);<\/p>\n<p>if (!first.equals(last))<\/p>\n<p>return false;<\/p>\n<p>else<\/p>\n<p>return checkPalindrome(s.substring(1, s.length() &#8211; 1));<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<h4>Output-<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"blend-mode\" src=\"https:\/\/www.simplilearn.com\/ice9\/free_resources_article_thumb\/palindrome.png\" alt=\"palindrome\" width=\"643\" height=\"452\" \/><\/p>\n<div class=\"engagingBanner\">\n<div class=\"detail-info-banner\" data-reactroot=\"\">\n<div class=\"left-clm\">\n<h4><strong>Full Stack Web Developer Course<\/strong><\/h4>\n<p><span class=\"discription\">To become an expert in MEAN Stack<\/span><\/p>\n<\/div>\n<div class=\"right-clm\"><img loading=\"lazy\" decoding=\"async\" class=\"blend-mode\" src=\"https:\/\/www.simplilearn.com\/ice9\/banners\/free_resources_banners\/lead_banners\/Vector_Full_Stack_Web_Developer.png\" alt=\"Full Stack Web Developer Course\" width=\"16\" height=\"9\" \/><\/div>\n<\/div>\n<\/div>\n<p>3. To get all the substrings of a string. Here is the code:<\/p>\n<p>public class TestSubstring {<\/p>\n<p>\/\/ Function to print all substrings of a string<\/p>\n<p>public static void SubString(String s, int n)<\/p>\n<p>{<\/p>\n<p>for (int i = 0; i &lt; n; i++)<\/p>\n<p>for (int j = i+1; j &lt;= n; j++)<\/p>\n<p>System.out.println(s.substring(i, j));<\/p>\n<p>}<\/p>\n<p>public static void main(String[] args)<\/p>\n<p>{<\/p>\n<p>String s = &#8220;defg&#8221;;<\/p>\n<p>SubString(s, s.length());<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<h4>Output-<\/h4>\n<\/article>\n<article>\n<h2><img loading=\"lazy\" decoding=\"async\" class=\"blend-mode\" src=\"https:\/\/www.simplilearn.com\/ice9\/free_resources_article_thumb\/allthesubstrings.png\" alt=\"allthesubstrings\" width=\"643\" height=\"468\" \/><\/h2>\n<\/article>\n<article>\n<h2 id=\"explain_the_variants_of_the_substring_method\"><span class=\"ez-toc-section\" id=\"Explain_the_variants_of_the_substring_method\"><\/span><strong>Explain the variants of the substring() method.<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The two variants of the substring() method are:<\/p>\n<ul>\n<li>String substring()<\/li>\n<li>String substring(startIndex, endIndex)<\/li>\n<\/ul>\n<p>Here is how two variants of the substring in the Java method can be used:<\/p>\n<p>1. To get the first m and last n characters of a string.<\/p>\n<p>Code:<\/p>\n<p>public class TestSubstring {<\/p>\n<p>public static void main(String[] args) {<\/p>\n<p>String str = &#8220;Substring in Java Tutorial&#8221;;<\/p>\n<p>System.out.println(&#8220;Last 8 char String: &#8221; + str.substring(str.length() &#8211; 8));<\/p>\n<p>System.out.println(&#8220;First 9 char String: &#8221; + str.substring(0, 9));<\/p>\n<p>System.out.println(&#8220;Topic name: &#8221; + str.substring(13, 26));<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<h4>Output:<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"blend-mode\" src=\"https:\/\/www.simplilearn.com\/ice9\/free_resources_article_thumb\/firstlast.png\" alt=\"firstlast\" width=\"512\" height=\"359\" \/><\/p>\n<div class=\"engagingBanner\">\n<div class=\"detail-info-banner\" data-reactroot=\"\">\n<div><\/div>\n<div class=\"right-clm\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"blend-mode\" src=\"https:\/\/www.simplilearn.com\/ice9\/banners\/free_resources_banners\/lead_banners\/vector_new.png\" alt=\"New Course: Full Stack Development for Beginners\" width=\"16\" height=\"9\" \/><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>2. It is interesting to note that substring in the Java method will return an empty string if the string&#8217;s length is passed as a parameter or if the same index is given as startIndex and endIndex. Here is an example:<\/p>\n<p>Code: public class TestSubstring {<\/p>\n<p>public static void main(String[] args) {<\/p>\n<p>String quote = &#8220;Substring in Java Tutorial&#8221;;<\/p>\n<p>String substr = quote.substring(quote.length()); System.out.println(substr.isEmpty());<\/p>\n<p>\/\/if begin = end<\/p>\n<p>String sub = quote.substring(3,3);<\/p>\n<p>System.out.println(sub.isEmpty());<\/p>\n<p>}}<\/p>\n<h4>Output:<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"blend-mode\" src=\"https:\/\/www.simplilearn.com\/ice9\/free_resources_article_thumb\/emptystring.png\" alt=\"emptystring\" width=\"637\" height=\"450\" \/><\/p>\n<p>3. Deleting the first character : Strings in Java start at index 0, i.e., the first character is 0 indexed. If you need to remove the first character, use substring(1). This returns the substring without the initial character, which equals deleting the first character.<\/p>\n<p>Code: public class TestSubstring {<\/p>\n<p>public static void main(String[] args) {<\/p>\n<p>String quote = &#8220;Substring in Java Tutorial&#8221;;<\/p>\n<p>String substr = quote.substring(1);<\/p>\n<p>System.out.println(substr);<\/p>\n<p>}}<\/p>\n<h4>Output:<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"blend-mode\" src=\"https:\/\/www.simplilearn.com\/ice9\/free_resources_article_thumb\/Deleting.png\" alt=\"Deleting\" width=\"639\" height=\"449\" \/><\/p>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\">Grab the opportunity to learn Python with Entri! Click Here<\/a><\/strong><\/p>\n<p>Note: If the end Index is not specified then the substring in Java method returns all characters from startIndex.<\/p>\n<p><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-25522670 size-full\" src=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1.png\" alt=\"Python and Machine Learning Rectangle\" width=\"970\" height=\"250\" srcset=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1.png 970w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1-300x77.png 300w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1-768x198.png 768w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1-750x193.png 750w\" sizes=\"auto, (max-width: 970px) 100vw, 970px\" \/><\/a><\/p>\n<\/article>\n<\/article>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>A substring is a subset or part of another string, or it is a contiguous sequence of characters within a string. For example, &#8220;Substring&#8221; is a substring of &#8220;Substring in Java.&#8221; What is a Substring in Java? Substring in Java is a commonly used method of java.lang.String class that is used to create smaller strings [&hellip;]<\/p>\n","protected":false},"author":111,"featured_media":25536086,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[802,1882],"tags":[],"class_list":["post-25535906","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","category-java-programming"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>All You Should Know About Substring in Java - Entri Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"All You Should Know About Substring in Java - Entri Blog\" \/>\n<meta property=\"og:description\" content=\"A substring is a subset or part of another string, or it is a contiguous sequence of characters within a string. For example, &#8220;Substring&#8221; is a substring of &#8220;Substring in Java.&#8221; What is a Substring in Java? Substring in Java is a commonly used method of java.lang.String class that is used to create smaller strings [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/\" \/>\n<meta property=\"og:site_name\" content=\"Entri Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/entri.me\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-07-30T20:55:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-23T09:34:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/All-You-Should-Know-About-Substring-in-Java..png\" \/>\n\t<meta property=\"og:image:width\" content=\"820\" \/>\n\t<meta property=\"og:image:height\" content=\"615\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Feeba Mahin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@entri_app\" \/>\n<meta name=\"twitter:site\" content=\"@entri_app\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Feeba Mahin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/\"},\"author\":{\"name\":\"Feeba Mahin\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/f036dab84abae3dcc9390a1110d95d36\"},\"headline\":\"All You Should Know About Substring in Java\",\"datePublished\":\"2022-07-30T20:55:25+00:00\",\"dateModified\":\"2022-11-23T09:34:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/\"},\"wordCount\":960,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/All-You-Should-Know-About-Substring-in-Java..png\",\"articleSection\":[\"Articles\",\"Java Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/\",\"url\":\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/\",\"name\":\"All You Should Know About Substring in Java - Entri Blog\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/All-You-Should-Know-About-Substring-in-Java..png\",\"datePublished\":\"2022-07-30T20:55:25+00:00\",\"dateModified\":\"2022-11-23T09:34:58+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#primaryimage\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/All-You-Should-Know-About-Substring-in-Java..png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/All-You-Should-Know-About-Substring-in-Java..png\",\"width\":820,\"height\":615,\"caption\":\"All You Should Know About Substring in Java.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/entri.app\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Entri Skilling\",\"item\":\"https:\/\/entri.app\/blog\/category\/entri-skilling\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Java Programming\",\"item\":\"https:\/\/entri.app\/blog\/category\/entri-skilling\/java-programming\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"All You Should Know About Substring in Java\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/entri.app\/blog\/#website\",\"url\":\"https:\/\/entri.app\/blog\/\",\"name\":\"Entri Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/entri.app\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/entri.app\/blog\/#organization\",\"name\":\"Entri App\",\"url\":\"https:\/\/entri.app\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"width\":989,\"height\":446,\"caption\":\"Entri App\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/entri.me\/\",\"https:\/\/x.com\/entri_app\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/f036dab84abae3dcc9390a1110d95d36\",\"name\":\"Feeba Mahin\",\"url\":\"https:\/\/entri.app\/blog\/author\/feeba123\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"All You Should Know About Substring in Java - Entri Blog","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:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/","og_locale":"en_US","og_type":"article","og_title":"All You Should Know About Substring in Java - Entri Blog","og_description":"A substring is a subset or part of another string, or it is a contiguous sequence of characters within a string. For example, &#8220;Substring&#8221; is a substring of &#8220;Substring in Java.&#8221; What is a Substring in Java? Substring in Java is a commonly used method of java.lang.String class that is used to create smaller strings [&hellip;]","og_url":"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/","og_site_name":"Entri Blog","article_publisher":"https:\/\/www.facebook.com\/entri.me\/","article_published_time":"2022-07-30T20:55:25+00:00","article_modified_time":"2022-11-23T09:34:58+00:00","og_image":[{"width":820,"height":615,"url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/All-You-Should-Know-About-Substring-in-Java..png","type":"image\/png"}],"author":"Feeba Mahin","twitter_card":"summary_large_image","twitter_creator":"@entri_app","twitter_site":"@entri_app","twitter_misc":{"Written by":"Feeba Mahin","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#article","isPartOf":{"@id":"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/"},"author":{"name":"Feeba Mahin","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/f036dab84abae3dcc9390a1110d95d36"},"headline":"All You Should Know About Substring in Java","datePublished":"2022-07-30T20:55:25+00:00","dateModified":"2022-11-23T09:34:58+00:00","mainEntityOfPage":{"@id":"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/"},"wordCount":960,"commentCount":0,"publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"image":{"@id":"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/All-You-Should-Know-About-Substring-in-Java..png","articleSection":["Articles","Java Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/","url":"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/","name":"All You Should Know About Substring in Java - Entri Blog","isPartOf":{"@id":"https:\/\/entri.app\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#primaryimage"},"image":{"@id":"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/All-You-Should-Know-About-Substring-in-Java..png","datePublished":"2022-07-30T20:55:25+00:00","dateModified":"2022-11-23T09:34:58+00:00","breadcrumb":{"@id":"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#primaryimage","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/All-You-Should-Know-About-Substring-in-Java..png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/All-You-Should-Know-About-Substring-in-Java..png","width":820,"height":615,"caption":"All You Should Know About Substring in Java."},{"@type":"BreadcrumbList","@id":"https:\/\/entri.app\/blog\/all-you-should-know-about-substring-in-java\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/entri.app\/blog\/"},{"@type":"ListItem","position":2,"name":"Entri Skilling","item":"https:\/\/entri.app\/blog\/category\/entri-skilling\/"},{"@type":"ListItem","position":3,"name":"Java Programming","item":"https:\/\/entri.app\/blog\/category\/entri-skilling\/java-programming\/"},{"@type":"ListItem","position":4,"name":"All You Should Know About Substring in Java"}]},{"@type":"WebSite","@id":"https:\/\/entri.app\/blog\/#website","url":"https:\/\/entri.app\/blog\/","name":"Entri Blog","description":"","publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/entri.app\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/entri.app\/blog\/#organization","name":"Entri App","url":"https:\/\/entri.app\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","width":989,"height":446,"caption":"Entri App"},"image":{"@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/entri.me\/","https:\/\/x.com\/entri_app"]},{"@type":"Person","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/f036dab84abae3dcc9390a1110d95d36","name":"Feeba Mahin","url":"https:\/\/entri.app\/blog\/author\/feeba123\/"}]}},"_links":{"self":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25535906","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/users\/111"}],"replies":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/comments?post=25535906"}],"version-history":[{"count":8,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25535906\/revisions"}],"predecessor-version":[{"id":25548022,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25535906\/revisions\/25548022"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media\/25536086"}],"wp:attachment":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media?parent=25535906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/categories?post=25535906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/tags?post=25535906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}