{"id":2835,"date":"2020-04-03T12:31:03","date_gmt":"2020-04-03T07:01:03","guid":{"rendered":"http:\/\/artoftesting.com\/?p=2835"},"modified":"2021-04-20T18:36:56","modified_gmt":"2021-04-20T13:06:56","slug":"string-handling-in-java","status":"publish","type":"post","link":"https:\/\/artoftesting.com\/string-handling-in-java","title":{"rendered":"String in Java"},"content":{"rendered":"\n<p>In this article, we are going to learn about String in Java. It is important to learn about Strings in an entirely different article because it has got a lot of applications in Java. Thus, it is highly significant to know what strings are, how they function in Java, their various methods and implementations.\u00a0<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Definition<\/strong><\/h2>\n\n\n\n<p>The String is a class in Java. All strings are objects of this class, which represent a sequence of characters written inside double-quotes. The String class is used to create and manipulate strings. They are used for storing text in Java and also work the same as an array of char values. E.g. &#8211; In Java, \u201chello\u201d, \u201cworld\u201d, \u201chello world\u201d, all are strings.\u00a0<br><\/p>\n\n\n\n<p>A string in Java is immutable, i.e., once created, their values cannot be changed. We will be discussing some methods used in String and it may seem that the string is being modified but what really happens is that a new string is created and returned containing the result of the string operation.<br><br>Strings are stored in a special memory area known as \u201cstring pool\u201d.<br><br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Creating a String in Java<\/strong><\/h2>\n\n\n\n<p>There are 2 methods of creating strings in Java.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Using String Literal<\/h3>\n\n\n\n<p>We can create a String using the following code-<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nclass Strings {\n    public static void main (String args&#x5B;]) {\n        String s = &quot;Java Programming&quot;;\n        System.out.println(s);\n    }\n}\n<\/pre><\/div>\n\n\n<p>This is the most common way of creating a Java string. If we try to create another string with the exact same value as an existing string, then instead of the creation of another string, only a reference will be created pointing to the same location of the already existing string in memory. To enunciate this point, take a look at this example-<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nclass Strings {\n    public static void main (String args&#x5B;]) {\n        String str1 = &quot;Java Programming&quot;;\n                 String str2 = \u201cJava Programming\u201d;\n        System.out.println(s);\n    }\n}\n<\/pre><\/div>\n\n\n<p>When str2 was created it found the same value stored in the string memory pool under the name of str1 so, instead of creating a new object, it referenced the memory location of str1. <br><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2.  Using new keyword<\/h3>\n\n\n\n<p>They can also be created using the \u201cnew\u201d keyword because, as mentioned earlier, String is a class and all strings are basically objects. Example-<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nclass Strings {\n    public static void main (String args&#x5B;]) {\n        String str1 = new String(&quot;Java Programming&quot;);\n        char arr&#x5B;] = {'h', 'e', 'l', 'l', 'o'};\n        String str2 = new String(arr);\n        System.out.println(str1);\n        System.out.println(str2);\n    }\n}\n<\/pre><\/div>\n\n\n<p>Using the \u201cnew\u201d keyword allocates free memory to the string every time it is created. If we try to create another string object having the same value as an existing string in the pool using the keyword \u201cnew\u201d, a new object will be created at a different memory location, unlike the case without using \u201cnew\u201d. <br><br><br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>String Class Methods<\/strong><\/h2>\n\n\n\n<p>There are numerous methods used in strings. These methods are stored in the java.lang.String class where java.lang is a package. We will go through each of the methods explaining them in detail with sample programs. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>int length()<\/strong><\/h3>\n\n\n\n<p>This method returns the length of the string.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;artoftesting&quot;;\nint ln = str.length();\nSystem.out.println(&quot;The length of the string is - &quot; + ln);\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>int compareTo(String)<\/strong><\/h3>\n\n\n\n<p>This method is used for comparing two strings and returns 0 if both are equal, a positive value if str1 is alphabetically or lexicographically greater than str2 and a negative value if it is the other way round. It is case-sensitive.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str1 = &quot;HELLO&quot;;\nString str2 = &quot;hello&quot;;\nSystem.out.println(str2.compareTo(str1));\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput: 32\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. <strong>int compareToIgnoreCase(String)<\/strong><\/h3>\n\n\n\n<p>As the name suggests, it performs the same functions as the above-mentioned method but it ignores the case, i.e., it is not case-sensitive. So the above code, replaced with this method, will give output as 0. <br><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4.  <strong>boolean equals(String)<\/strong><\/h3>\n\n\n\n<p>This method gives us true if two strings are equal otherwise false.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str1 = &quot;HELLO&quot;;\nString str2 = &quot;hello&quot;;\nSystem.out.println(str2.equals(str1));\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput: false\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. <strong>boolean equalsIgnoreCase(String)<\/strong><\/h3>\n\n\n\n<p>Just like before, this performs the same function as equals() but is not case-sensitive. Thus the above example if implemented by equalsIgnoreCase() will give output as true. <br><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6. <strong>String concat(String)<\/strong><\/h3>\n\n\n\n<p>This method is used to concatenate two strings. The second string will be appended to the end of the first string. Finally, it returns the resultant string after concatenation.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str1 = &quot;Java&quot;;\nString str2 = &quot;Programming&quot;;\nSystem.out.println(str1.concat(str2));\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput: JavaProgramming\n<\/pre><\/div>\n\n\n<p> We can also use the \u2018+\u2019 operator to concatenate two strings like this-<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nstr1 + str2 \nstr1 + &quot; &quot; + str2\n<\/pre><\/div>\n\n\n<p> We have often used this in print statements.<br><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">7. <strong>String toUpperCase()<\/strong><\/h3>\n\n\n\n<p>This method is used to convert a string to upper case, i.e., all capital letters. Basically, it returns the updated string with all letters in the upper case.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;Java&quot;;\nSystem.out.println(str.toUpperCase());\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput: JAVA\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">8. <strong>String toLowerCase()<\/strong><\/h3>\n\n\n\n<p>Just like the above method, it changes the case of the string but to the lower case.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;JAvA&quot;;\nSystem.out.println(str.toLowerCase());\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput: java\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">9. <strong>char charAt(int)<\/strong><\/h3>\n\n\n\n<p>This method is used to find the character present at a particular index specified by the user. Remember that the index of a string starts from 0 and ends at length()-1, just like in arrays. The index specified can be any value from 0 to length()-1. The spaces in a string are also considered at characters and are given an index so, do not miss that.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;JAVA ProgramMING&quot;;\nSystem.out.println(str.charAt(5));\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput: P\n<\/pre><\/div>\n\n\n<p>If you try to access the index less than 0 or greater than the allowed index, you will get a StringIndexOutOfBoundsException.<br><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">10. <strong>String format()<\/strong><\/h3>\n\n\n\n<p>String in Java provides format() which returns a String object and allows you to create a formatted string that can be reused. This format is similar to the printf() in C and Java. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;Java Program&quot;;\n\n\/\/ Combining two strings\nString str1 = String.format(&quot;The value of string is %s&quot;, str);\n\n\/\/ Outputs float number upto 10 decimal places\nString str2 = String.format(&quot;The value of float is %.10f&quot;, 23.73925);\n\n\/\/ Outputs float number with 14 digits before the decimal point and 3 after it.\nString str3 = String.format(&quot;The value of float2 is %14.3f&quot;, 23.73925);\n\n\/\/ Printing the formatted strings\nSystem.out.println(str1);\nSystem.out.println(str2);\nSystem.out.println(str3);\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">11. <strong>String substring()<\/strong><\/h3>\n\n\n\n<p>This method is used to get a substring of the string, i.e., a part of the string. There are two syntaxes to use this method.<\/p>\n\n\n\n<p>a.  <strong>String substring(int beginIndex)<\/strong> &#8211; It is used to get the substring from the beginIndex till the end of the string. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;Java Programming&quot;;\nSystem.out.println(str.substring(5));\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput: Programming\n<\/pre><\/div>\n\n\n<p><br>b. <strong>String substring(int beginIndex, int endIndex)<\/strong> &#8211; It is used to get the substring from beginIndex till endIndex-1. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;Java Programming&quot;;\nSystem.out.println(str.substring(5, 12));\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput: Program\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">12. <strong>boolean contains(String)<\/strong><\/h3>\n\n\n\n<p>This method is used to check if the string contains a particular substring or not. It returns true if the substring is present in the String else returns false. It is case-sensitive and takes only strings as arguments, not characters. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;Java Programming&quot;;\nSystem.out.println(str.contains(&quot;ava&quot;));\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput: true\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">13. <strong>String replace(String1, String2)<\/strong><\/h3>\n\n\n\n<p>This method is used for replacing all occurrences of string1 in the string with string2. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;Java Programming&quot;;\nstr = str.replace(&quot;a&quot;, &quot;i&quot;);\nSystem.out.println(str);\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput: Jivi Progrimmimg\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">14. <strong>String replaceFirst(string1, string2)<\/strong><\/h3>\n\n\n\n<p>This method is used to replace only the first occurrence of string1 with string2. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;Java is a good language. I love Java&quot;;\nString newstr1 = str.replaceFirst(&quot;Java&quot;, &quot;JAVA&quot;);\nString newstr2 = str.replaceFirst(&quot;a&quot;, &quot;A&quot;);\n\nSystem.out.println(str);\nSystem.out.println(newstr1);\nSystem.out.println(newstr2);\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nJava is a good language. I love Java\nJAVA is a good language. I love Java\nJAva is a good language. I love Java\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">15. <strong>String replaceAll()<\/strong><\/h3>\n\n\n\n<p>This method is exactly like replace() and replaces all occurrences of string1 with string2. Example to remove all spaces-<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;Java is a good language. I love Java&quot;;\nString replaceString=str.replaceAll(&quot;\\\\s&quot;,&quot;&quot;);\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nJavaisagoodlanguage.IloveJava.\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">16. <strong>int indexOf(String)<\/strong><\/h3>\n\n\n\n<p>This method is used for finding the index of a character or a string from a given string. It returns the index of the first occurrence of the character\/string. It is case-sensitive.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;JAVA ProgramMING&quot;;\nSystem.out.println(str.indexOf(&quot;VA&quot;));\nSystem.out.println(str.indexOf(\u2018A\u2019));\nSystem.out.println(str.indexOf(\u201ca\u201d));\nSystem.out.println(str.indexOf(\u201cMm\u201d));\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput-\n2\n1\n10\n-1\n<\/pre><\/div>\n\n\n<p> If the string\/character is not found in the string -1 is returned.<br><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">17. <strong>String trim()<\/strong><\/h3>\n\n\n\n<p>This method is used to remove all the extra spaces from the beginning and end of a string but not the middle.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;  Java Programming    &quot;;\nSystem.out.println(str + str.length());\nSystem.out.println(str.trim() + str.length());\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput-\nJava Programming    22\nJava Prgramming22\n<\/pre><\/div>\n\n\n<p>Note that the trimmed string has been printed but the length of the string remains unchanged. Can you guess why that happened? Because String is immutable. The actual string will never change. Only the modified result is stored in another temporary variable and returned without making any changes in the original string. <br><br>You\u2019ll notice that if we print the string again, it will be the same with spaces. Thus, one method to permanently save your changes is to save the result in another string and use it or save it in the same string and the value will be rewritten. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString s = str.trim();\nSystem.out.println(s + s.length());\n<\/pre><\/div>\n\n\n<p> Or<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nstr = str.trim();\nSystem.out.println(str + str.length());\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput: Java Programming16\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">18. <strong>String valueOf()<\/strong><\/h3>\n\n\n\n<p>This method is used to convert any data type to String type. It can convert double, float, int, char, and objects to String type. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndouble n = 34.96348;\nString ns = String.valueOf(n);\nSystem.out.println(ns + 20);\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput: 34.9634820\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">19. <strong>boolean startsWith(String)<\/strong><\/h3>\n\n\n\n<p>This method is used to check whether a given string starts with a particular substring. It returns true if the string starts with the substring else returns false. It is case-sensitive. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;Java Programming&quot;;\nSystem.out.println(str.startsWith(&quot;Java&quot;)); \/\/ true\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">20. <strong>boolean endsWith(String)<\/strong><\/h3>\n\n\n\n<p>Similar to the above-mentioned method, the endsWith() checks whether the given string ends with a particular substring and returns a boolean value. It is also case-sensitive. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;Java Programming&quot;;\nSystem.out.println(str.endsWith(&quot;min&quot;)); \/\/ false\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">21. <strong>int lastIndexOf()<\/strong><\/h3>\n\n\n\n<p>This method is used to find the last occurrence of a character or a string in a given string. It returns the index of the last occurrence of the character\/string. It is also case-sensitive. There are two types-<\/p>\n\n\n\n<p>a.  int lastIndexOf(String)<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;Java Programming&quot;;\nSystem.out.println(str.lastIndexOf(&quot;a&quot;)); \/\/Outputs 10\n<\/pre><\/div>\n\n\n<p><br>b. int lastIndexOf(String, int beginIndex) &#8211; It starts searching from beginIndex.It considers the beginIndex as the end of the string and returns the last occurrence of the String or character.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;Java Programming&quot;;\nSystem.out.println(str.lastIndexOf(\u2018a\u2019,5)); \/\/Outputs 3\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">22. <strong>boolean isEmpty()<\/strong><\/h3>\n\n\n\n<p>This method is used to check whether a string is empty or not. It returns a boolean value. A string is said to be empty if its length is 0.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;Java Programming&quot;;\nString s = &quot;&quot;;\nSystem.out.println(str.isEmpty()); \/\/ false\nSystem.out.println(s.isEmpty()); \/\/ true\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">23. <strong>int hashCode()<\/strong><\/h3>\n\n\n\n<p>This method is used to return the hashcode of a string. Every string can be converted to an integer value called the hashcode which can be very useful for checking the equality of two large strings. It is calculated by a certain formula. <br><br>Hashcodes for two exactly equal strings will always have the same hashcode. While this method can be very beneficial, it is not flawless. The hashcodes of two unequal strings can sometimes coincide as they are based on a mathematical formula. Although the probability of happening is very less.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str2 = &quot;hello&quot;;\nString str3 = &quot;hello&quot;;\nString str4 = &quot;Hello&quot;;\n \nString str5 = str4;\n  \nSystem.out.println(&quot;Hash Code of:\\n&quot;);\nSystem.out.println(&quot;Empty string: &quot; + str1.hashCode());\nSystem.out.println(str2 + &quot;: &quot; + str2.hashCode());\nSystem.out.println(str3 +&quot;: &quot; + str3.hashCode());\nSystem.out.println(str4 + &quot;: &quot; + str4.hashCode());\nSystem.out.println(str5 + &quot;: &quot; + str5.hashCode());\n \nSystem.out.println(&quot;\\nAa: &quot; + &quot;Aa&quot;.hashCode());\nSystem.out.println(&quot;BB: &quot; + &quot;BB&quot;.hashCode());\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput-\nHash code of: \nEmpty string: 0\nhello: 99162322\nhello: 99162322\nHello: 69609650\nHello: 69609650\n\nAa: 2112\nBB: 2112\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">24. <strong>String[] split()<\/strong><\/h3>\n\n\n\n<p>This method is used to split a string based on a delimiter\/regular expression. It returns an array of Strings after splitting the given string based on the delimiter. There are two types of split() in Java Strings-<\/p>\n\n\n\n<p>a. String split(String) &#8211; This method simply splits the string based on the delimiter given in the form of a string with no limitation on the number of split strings.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString s = &quot;I Love Java Programming&quot;;\nString&#x5B;] strarr = s.split(&quot; &quot;); \/\/ Delimiter is space\nfor (String i : strarr)\n\tSystem.out.println(i);\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput-\nI\nLove\nJava \nProgramming\n<\/pre><\/div>\n\n\n<p> <br>b.  String split(String, int) &#8211; This method limits the number of strings to be split based on the delimiter. It will return only the limited number of strings in the array as per the limit given even if splits are possible after that. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString s = &quot;I Love Java Programming&quot;;\n\n\/\/ Delimiter is space with limit 2\nString&#x5B;] strarr = s.split(&quot; &quot;, 2);\n\nfor (String i : strarr)\n\tSystem.out.println(i);\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput-\nI\nLove Java Programming\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">25. <strong>char[] toCharArray()<\/strong><\/h3>\n\n\n\n<p>This method converts a given string to an array of characters. The length of the character array will be the same as the length of the String. This method returns a newly allocated character array. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString s = &quot;Java&quot;;\nchar&#x5B;] schararr = s.toCharArray();\nfor (char i : schararr) \n\tSystem.out.println(i);\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\nOutput-\nJ\na\nv\na\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">26. <strong>String toString()<\/strong><\/h3>\n\n\n\n<p>This method is used to basically convert a string to itself. It returns itself, so technically no conversion takes place. It does not accept any parameters. Since this method performs no changes on the string, it need not be called explicitly, it is usually called implicitly. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str = &quot;Java Programming&quot;;\nString str2 = str.toString();\nSystem.out.println(str2);\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput-\nJava Programming\n<\/pre><\/div>\n\n\n<p><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">27. <strong>String join()<\/strong><\/h3>\n\n\n\n<p>This method is used to join strings together using a delimiter. The first argument specifies the delimiter to be used and the rest are the strings to be joined together. If null is present as one of the strings then only an empty string will be added.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nString str=String.join(&quot;^&quot;,&quot;Java&quot;,&quot;Is&quot;,&quot;Awesome&quot;);  \nSystem.out.println(str); \nString str2=String.join(&quot;^&quot;,&quot;Java&quot;,&quot;&quot;,&quot;Awesome&quot;);\nSystem.out.println(str2);\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nOutput-\nJava^Is^Awesome\nJava^^Awesome\n<\/pre><\/div>\n\n\n<div style=\"height:42px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>With this, we have come to the end of the topic &#8220;String in Java&#8221;. We learned what strings are in Java, how to create strings, manipulate them using the various string methods. The methods stated above may look a lot but a little practice can make you almost perfect and acquainted with all these methods. <br><br>Their applications are important to know because they will be very useful while writing Java programs and using Strings. I hope you liked the article and practice, experiment, and enjoy learning.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Don&#8217;t miss out<br><a href=\"http:\/\/artoftesting.com\/java-for-testers\"><strong>Core Java Tutorial Series<\/strong><\/a><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we are going to learn about String in Java. It is important to learn about Strings in an entirely different article because it has got a lot of applications in Java. Thus, it is highly significant to know what strings are, how they function in Java, their various methods and implementations.&nbsp; Definition &#8230; <a title=\"String in Java\" class=\"read-more\" href=\"https:\/\/artoftesting.com\/string-handling-in-java\" aria-label=\"Read more about String in Java\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":2836,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,20],"tags":[],"class_list":["post-2835","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-automation-testing","category-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>String in Java | String Class Explained with Examples<\/title>\n<meta name=\"description\" content=\"String has got a lot of applications in Java and thus, it is highly significant to know what strings are, how they function in Java, their various methods and implementations.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/artoftesting.com\/string-handling-in-java\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"String in Java | String Class Explained with Examples\" \/>\n<meta property=\"og:description\" content=\"String has got a lot of applications in Java and thus, it is highly significant to know what strings are, how they function in Java, their various methods and implementations.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/artoftesting.com\/string-handling-in-java\" \/>\n<meta property=\"og:site_name\" content=\"ArtOfTesting\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/artoftesting\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-03T07:01:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-20T13:06:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/artoftesting.com\/wp-content\/uploads\/2020\/04\/string-in-java.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"728\" \/>\n\t<meta property=\"og:image:height\" content=\"416\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Kuldeep Rana\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@theartoftesting\" \/>\n<meta name=\"twitter:site\" content=\"@theartoftesting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kuldeep Rana\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/artoftesting.com\/string-handling-in-java#article\",\"isPartOf\":{\"@id\":\"https:\/\/artoftesting.com\/string-handling-in-java\"},\"author\":{\"name\":\"Kuldeep Rana\",\"@id\":\"https:\/\/artoftesting.com\/#\/schema\/person\/7846d06225b52c778d160becf65996a5\"},\"headline\":\"String in Java\",\"datePublished\":\"2020-04-03T07:01:03+00:00\",\"dateModified\":\"2021-04-20T13:06:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/artoftesting.com\/string-handling-in-java\"},\"wordCount\":1774,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/artoftesting.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/artoftesting.com\/string-handling-in-java#primaryimage\"},\"thumbnailUrl\":\"https:\/\/artoftesting.com\/wp-content\/uploads\/2020\/04\/string-in-java.jpg\",\"articleSection\":[\"Automation Testing\",\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/artoftesting.com\/string-handling-in-java#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/artoftesting.com\/string-handling-in-java\",\"url\":\"https:\/\/artoftesting.com\/string-handling-in-java\",\"name\":\"String in Java | String Class Explained with Examples\",\"isPartOf\":{\"@id\":\"https:\/\/artoftesting.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/artoftesting.com\/string-handling-in-java#primaryimage\"},\"image\":{\"@id\":\"https:\/\/artoftesting.com\/string-handling-in-java#primaryimage\"},\"thumbnailUrl\":\"https:\/\/artoftesting.com\/wp-content\/uploads\/2020\/04\/string-in-java.jpg\",\"datePublished\":\"2020-04-03T07:01:03+00:00\",\"dateModified\":\"2021-04-20T13:06:56+00:00\",\"description\":\"String has got a lot of applications in Java and thus, it is highly significant to know what strings are, how they function in Java, their various methods and implementations.\",\"breadcrumb\":{\"@id\":\"https:\/\/artoftesting.com\/string-handling-in-java#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/artoftesting.com\/string-handling-in-java\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/artoftesting.com\/string-handling-in-java#primaryimage\",\"url\":\"https:\/\/artoftesting.com\/wp-content\/uploads\/2020\/04\/string-in-java.jpg\",\"contentUrl\":\"https:\/\/artoftesting.com\/wp-content\/uploads\/2020\/04\/string-in-java.jpg\",\"width\":728,\"height\":416,\"caption\":\"Strings in Java\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/artoftesting.com\/string-handling-in-java#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/artoftesting.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Automation Testing\",\"item\":\"https:\/\/artoftesting.com\/category\/automation-testing\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"String in Java\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/artoftesting.com\/#website\",\"url\":\"https:\/\/artoftesting.com\/\",\"name\":\"ArtOfTesting\",\"description\":\"A Beginners Guide to Testing\",\"publisher\":{\"@id\":\"https:\/\/artoftesting.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/artoftesting.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/artoftesting.com\/#organization\",\"name\":\"ArtOfTesting\",\"url\":\"https:\/\/artoftesting.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/artoftesting.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Artoftesting_logo.png\",\"contentUrl\":\"http:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Artoftesting_logo.png\",\"width\":400,\"height\":60,\"caption\":\"ArtOfTesting\"},\"image\":{\"@id\":\"https:\/\/artoftesting.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/facebook.com\/artoftesting\",\"https:\/\/x.com\/theartoftesting\",\"https:\/\/www.linkedin.com\/groups\/4797819\/\",\"https:\/\/in.pinterest.com\/artoftesting\/\",\"https:\/\/www.youtube.com\/channel\/UCQ9PUVenvvyrUdDQ9yKn31Q\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/artoftesting.com\/#\/schema\/person\/7846d06225b52c778d160becf65996a5\",\"name\":\"Kuldeep Rana\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/artoftesting.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cb5979a4b81ca7739c75080e473fad391a8665364e72abaddec9002dd4553326?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cb5979a4b81ca7739c75080e473fad391a8665364e72abaddec9002dd4553326?s=96&d=mm&r=g\",\"caption\":\"Kuldeep Rana\"},\"description\":\"Kuldeep is the founder and lead author of ArtOfTesting. He is skilled in test automation, performance testing, big data, and CI-CD. He brings his decade of experience to his current role where he is dedicated to educating the QA professionals.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"String in Java | String Class Explained with Examples","description":"String has got a lot of applications in Java and thus, it is highly significant to know what strings are, how they function in Java, their various methods and implementations.","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:\/\/artoftesting.com\/string-handling-in-java","og_locale":"en_US","og_type":"article","og_title":"String in Java | String Class Explained with Examples","og_description":"String has got a lot of applications in Java and thus, it is highly significant to know what strings are, how they function in Java, their various methods and implementations.","og_url":"https:\/\/artoftesting.com\/string-handling-in-java","og_site_name":"ArtOfTesting","article_publisher":"https:\/\/facebook.com\/artoftesting","article_published_time":"2020-04-03T07:01:03+00:00","article_modified_time":"2021-04-20T13:06:56+00:00","og_image":[{"width":728,"height":416,"url":"https:\/\/artoftesting.com\/wp-content\/uploads\/2020\/04\/string-in-java.jpg","type":"image\/jpeg"}],"author":"Kuldeep Rana","twitter_card":"summary_large_image","twitter_creator":"@theartoftesting","twitter_site":"@theartoftesting","twitter_misc":{"Written by":"Kuldeep Rana","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/artoftesting.com\/string-handling-in-java#article","isPartOf":{"@id":"https:\/\/artoftesting.com\/string-handling-in-java"},"author":{"name":"Kuldeep Rana","@id":"https:\/\/artoftesting.com\/#\/schema\/person\/7846d06225b52c778d160becf65996a5"},"headline":"String in Java","datePublished":"2020-04-03T07:01:03+00:00","dateModified":"2021-04-20T13:06:56+00:00","mainEntityOfPage":{"@id":"https:\/\/artoftesting.com\/string-handling-in-java"},"wordCount":1774,"commentCount":0,"publisher":{"@id":"https:\/\/artoftesting.com\/#organization"},"image":{"@id":"https:\/\/artoftesting.com\/string-handling-in-java#primaryimage"},"thumbnailUrl":"https:\/\/artoftesting.com\/wp-content\/uploads\/2020\/04\/string-in-java.jpg","articleSection":["Automation Testing","Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/artoftesting.com\/string-handling-in-java#respond"]}]},{"@type":"WebPage","@id":"https:\/\/artoftesting.com\/string-handling-in-java","url":"https:\/\/artoftesting.com\/string-handling-in-java","name":"String in Java | String Class Explained with Examples","isPartOf":{"@id":"https:\/\/artoftesting.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/artoftesting.com\/string-handling-in-java#primaryimage"},"image":{"@id":"https:\/\/artoftesting.com\/string-handling-in-java#primaryimage"},"thumbnailUrl":"https:\/\/artoftesting.com\/wp-content\/uploads\/2020\/04\/string-in-java.jpg","datePublished":"2020-04-03T07:01:03+00:00","dateModified":"2021-04-20T13:06:56+00:00","description":"String has got a lot of applications in Java and thus, it is highly significant to know what strings are, how they function in Java, their various methods and implementations.","breadcrumb":{"@id":"https:\/\/artoftesting.com\/string-handling-in-java#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/artoftesting.com\/string-handling-in-java"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/artoftesting.com\/string-handling-in-java#primaryimage","url":"https:\/\/artoftesting.com\/wp-content\/uploads\/2020\/04\/string-in-java.jpg","contentUrl":"https:\/\/artoftesting.com\/wp-content\/uploads\/2020\/04\/string-in-java.jpg","width":728,"height":416,"caption":"Strings in Java"},{"@type":"BreadcrumbList","@id":"https:\/\/artoftesting.com\/string-handling-in-java#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/artoftesting.com\/"},{"@type":"ListItem","position":2,"name":"Automation Testing","item":"https:\/\/artoftesting.com\/category\/automation-testing"},{"@type":"ListItem","position":3,"name":"String in Java"}]},{"@type":"WebSite","@id":"https:\/\/artoftesting.com\/#website","url":"https:\/\/artoftesting.com\/","name":"ArtOfTesting","description":"A Beginners Guide to Testing","publisher":{"@id":"https:\/\/artoftesting.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/artoftesting.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/artoftesting.com\/#organization","name":"ArtOfTesting","url":"https:\/\/artoftesting.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/artoftesting.com\/#\/schema\/logo\/image\/","url":"http:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Artoftesting_logo.png","contentUrl":"http:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Artoftesting_logo.png","width":400,"height":60,"caption":"ArtOfTesting"},"image":{"@id":"https:\/\/artoftesting.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/facebook.com\/artoftesting","https:\/\/x.com\/theartoftesting","https:\/\/www.linkedin.com\/groups\/4797819\/","https:\/\/in.pinterest.com\/artoftesting\/","https:\/\/www.youtube.com\/channel\/UCQ9PUVenvvyrUdDQ9yKn31Q"]},{"@type":"Person","@id":"https:\/\/artoftesting.com\/#\/schema\/person\/7846d06225b52c778d160becf65996a5","name":"Kuldeep Rana","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/artoftesting.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cb5979a4b81ca7739c75080e473fad391a8665364e72abaddec9002dd4553326?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cb5979a4b81ca7739c75080e473fad391a8665364e72abaddec9002dd4553326?s=96&d=mm&r=g","caption":"Kuldeep Rana"},"description":"Kuldeep is the founder and lead author of ArtOfTesting. He is skilled in test automation, performance testing, big data, and CI-CD. He brings his decade of experience to his current role where he is dedicated to educating the QA professionals."}]}},"_links":{"self":[{"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/posts\/2835","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/comments?post=2835"}],"version-history":[{"count":1,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/posts\/2835\/revisions"}],"predecessor-version":[{"id":4885,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/posts\/2835\/revisions\/4885"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/media\/2836"}],"wp:attachment":[{"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/media?parent=2835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/categories?post=2835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/tags?post=2835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}