{"id":99,"date":"2019-01-18T23:39:45","date_gmt":"2019-01-18T23:39:45","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/java\/?p=99"},"modified":"2020-08-06T09:53:53","modified_gmt":"2020-08-06T09:53:53","slug":"16-java-the-string-class","status":"publish","type":"post","link":"https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/","title":{"rendered":"Java &#8211; The String Class"},"content":{"rendered":"<p>We have previously covered:\u00a0<a href=\"https:\/\/www.kindsonthegenius.com\/java\/java-the-number-class\/\">The Number Class<\/a>\u00a0and\u00a0\u00a0<a href=\"https:\/\/www.kindsonthegenius.com\/java\/java-the-character-class\/\">The Character Class<\/a>. In this tutorial, we would examine the String class.<\/p>\n<p>I believe you understand these by now. If not, I rather suggest you take some time to review them. Today we would cover the following:<\/p>\n<ol>\n<li><a href=\"#t1\">Introduction to Strings<\/a><\/li>\n<li><a href=\"#t2\">Creating a String<\/a><\/li>\n<li><a href=\"#t3\">Length of a String<\/a><\/li>\n<li><a href=\"#t4\">Combining Strings<\/a><\/li>\n<li><a href=\"#t5\">Formatting Strings<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t1\">1. Introduction to Strings<\/strong><\/h4>\n<p>Now, we are going to look at the String class.<\/p>\n<p>First, keep in mind that Java does not provide a primitive type for strings. So we are left with only the wrapper class String. It therefore means that all strings in Java are objects. You need to stick with that. You will find it interesting though. I will also want you to know that a string object is also a char array. That is array of char types\/<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t2\">2. Creating a String<\/strong><\/h4>\n<p>First you need to learn how to create a string. There are two ways of doing this:<\/p>\n<ul>\n<li>first: by assigning a string literal<\/li>\n<li>second: by using the string constructor<\/li>\n<li>third: by creating a string from a char array<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>I therefore provide the program in Listing 1.0. You can see how strings are created using these three methods. I also recommend you make sure to run it yourself.<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">StringTester<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\r\n\t<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span><span style=\"color: #333333;\">(<\/span>String<span style=\"color: #333333;\">[]<\/span> args<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t<span style=\"color: #888888;\">\/\/first method<\/span>\r\n\t\tString title <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">\"Java Tutorials\"<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t\r\n\t\t<span style=\"color: #888888;\">\/\/second method<\/span>\r\n\t\tString messgage <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> String<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"Good Job!\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\t\r\n\t\t<span style=\"color: #888888;\">\/\/third method: a char array<\/span>\r\n\t\t<span style=\"color: #333399; font-weight: bold;\">char<\/span><span style=\"color: #333333;\">[]<\/span> charArray <span style=\"color: #333333;\">=<\/span> <span style=\"color: #333333;\">{<\/span><span style=\"color: #0044dd;\">'H'<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0044dd;\">'e'<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0044dd;\">'l'<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0044dd;\">'l'<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0044dd;\">'o'<\/span><span style=\"color: #333333;\">};<\/span>\r\n\t\tString greeting <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> String<span style=\"color: #333333;\">(<\/span>charArray<span style=\"color: #333333;\">);<\/span>\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>Listing 1.0: Ways to create a string<\/p>\n<p>&nbsp;<\/p>\n<p>It is noteworthy that Strings are immutable. You need to keep this in mind. Hence, once a string object is created, then it cannot be changed. To be able to make changes to strings, we use the String Buffer and String Builder classes.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t3\">3. Length of a String<\/strong><\/h4>\n<p>You can get information about string objects. To do this, you use methods provided by the string classed. These methods are known as <strong>accessor methods.<\/strong><\/p>\n<p>One of such methods, you can use is the length() method. You use this method to get the length of the string. That is how many characters are in the string.<\/p>\n<p>I recommend you run the program in Listing 1.1. In this way, you understand how to use the length() method.<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">StringTester<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\r\n\t<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span><span style=\"color: #333333;\">(<\/span>String<span style=\"color: #333333;\">[]<\/span> args<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t<span style=\"color: #888888;\">\/\/first method<\/span>\r\n\t\tString title <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">\"Java Tutorials\"<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t\r\n\t\t<span style=\"color: #333399; font-weight: bold;\">int<\/span> length <span style=\"color: #333333;\">=<\/span> title<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">length<\/span><span style=\"color: #333333;\">();<\/span>\r\n\t\t\r\n\t\tSystem<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">print<\/span><span style=\"color: #333333;\">(<\/span>length<span style=\"color: #333333;\">);<\/span>\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>Listing 1.1: Program to get the the length of a string<\/p>\n<p>&nbsp;<\/p>\n<p>If you run the program in Listing 1.1, then you will get an output of 14. You should also note that the white-space between the two words is also a character.<\/p>\n<p>&nbsp;<\/p>\n<p><strong id=\"t4\">4. Combining Strings (Concatenation)<\/strong><\/p>\n<p>I therefore suggest you add this word to your list of important words &#8211; concatenation. It means combining two or more strings to form one string. So we say something like: to concatenate two strings.<\/p>\n<p>This is achieved by either of two ways:<\/p>\n<ul>\n<li>by using the concatenation operator (+)<\/li>\n<li>by using the concat() method. I think it&#8217;s fairly easy to use.<\/li>\n<\/ul>\n<p>So to combine two strings, string1 and string2 using the concatenation operator, you say:<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">string3 <span style=\"color: #333333;\">=<\/span> string1 <span style=\"color: #333333;\">+<\/span> string2\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>But to use the concat method, you\u00a0 say:<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">string3 <span style=\"color: #333333;\">=<\/span> string1<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">concat<\/span><span style=\"color: #333333;\">(<\/span>string2<span style=\"color: #333333;\">)<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>So take a loop at the program in Listing 1.2 below. I suggest you run it yourself in your own IDE.<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">StringTester<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\r\n\t<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span><span style=\"color: #333333;\">(<\/span>String<span style=\"color: #333333;\">[]<\/span> args<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\tString string1 <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">\"Java\"<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\tString string2 <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">\"Tutorials\"<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t\r\n\t\t<span style=\"color: #888888;\">\/\/using concatenation operator (+)<\/span>\r\n\t\tString string3 <span style=\"color: #333333;\">=<\/span> string1 <span style=\"color: #333333;\">+<\/span> string2<span style=\"color: #333333;\">;<\/span>\r\n\t\t\r\n\t\t<span style=\"color: #888888;\">\/\/using the concat method<\/span>\r\n\t\tString string4 <span style=\"color: #333333;\">=<\/span> string1<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">concat<\/span><span style=\"color: #333333;\">(<\/span>string2<span style=\"color: #333333;\">);<\/span>\r\n\t\t\r\n\t\tSystem<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span>string3<span style=\"color: #333333;\">);<\/span>\r\n\t\tSystem<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span>string4<span style=\"color: #333333;\">);<\/span>\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>Listing 1.2: Combining two strings<\/p>\n<p>&nbsp;<\/p>\n<p>If you run the code in Listing 1.2, it would display the same result. JavaTutorials. So, string3 and string4 would hold the same value<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t5\">5. Formatting Strings<\/strong><\/h4>\n<p>You can you two functions to create formatted strings:<\/p>\n<ul>\n<li>the printf() function<\/li>\n<li>the format() function<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>While the printf() function is available under System.out namespace, the format() method is a method in the String class. Nevertheless, you can use both to achieve the same result.<\/p>\n<p>&nbsp;<\/p>\n<p>Take an example in the code below.<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">StringTester<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\r\n\t<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span><span style=\"color: #333333;\">(<\/span>String<span style=\"color: #333333;\">[]<\/span> args<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\tString name <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">\"Osondu Mills\"<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t<span style=\"color: #333399; font-weight: bold;\">float<\/span> score <span style=\"color: #333333;\">=<\/span> <span style=\"color: #6600ee; font-weight: bold;\">87.09f<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t<span style=\"color: #333399; font-weight: bold;\">int<\/span> seat_number <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">14<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t\r\n\t\tSystem<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">printf<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"My name is %s \"<\/span> <span style=\"color: #333333;\">+<\/span>\r\n\t\t\t\t<span style=\"background-color: #fff0f0;\">\"and my score is %f and \"<\/span> <span style=\"color: #333333;\">+<\/span>\r\n\t\t\t\t<span style=\"background-color: #fff0f0;\">\"my seat number is %d \"<\/span><span style=\"color: #333333;\">,<\/span>\r\n\t\t\t\tname<span style=\"color: #333333;\">,<\/span> score<span style=\"color: #333333;\">,<\/span> seat_number<span style=\"color: #333333;\">);<\/span>\t\t\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>Listing 1.3: Formatting String using<strong> printf()<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>If you run the program above in Listing 1.3, the you will have the result below<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">My name is Osondu Mills and my score is <span style=\"color: #6600ee; font-weight: bold;\">87.089996<\/span> and my seat number is <span style=\"color: #0000dd; font-weight: bold;\">14<\/span> \r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>%s, %f and %d are called format specifiers. %s is used to represent strings, %d is used to represent integers while %f is used to represent floats<\/p>\n<p>So what happens here is the each formats specifier is replaced with the value of the corresponding string variable.<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>%s is replaced with &#8220;Osondu Mills&#8221;<\/li>\n<li>%f is replaced with 87.09<\/li>\n<li>%d is replaced with 14<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>Hence, you have the specified output. Now the code in Listing 1.4 does exactly the same thing. But this time, using the format method of the string class.<\/p>\n<p>You can also try it.<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">StringTester<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\r\n\t<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span><span style=\"color: #333333;\">(<\/span>String<span style=\"color: #333333;\">[]<\/span> args<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\tString name <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">\"Osondu Mills\"<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t<span style=\"color: #333399; font-weight: bold;\">float<\/span> score <span style=\"color: #333333;\">=<\/span> <span style=\"color: #6600ee; font-weight: bold;\">87.09f<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t<span style=\"color: #333399; font-weight: bold;\">int<\/span> seat_number <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">14<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\t\r\n\t\t<span style=\"color: #888888;\">\/\/Using the format method<\/span>\r\n\t\tString details <span style=\"color: #333333;\">=<\/span> String<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">format<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"My name is %s \"<\/span> <span style=\"color: #333333;\">+<\/span>\r\n\t\t\t\t<span style=\"background-color: #fff0f0;\">\"and my score is %f and \"<\/span> <span style=\"color: #333333;\">+<\/span>\r\n\t\t\t\t<span style=\"background-color: #fff0f0;\">\"my seat number is %d \"<\/span><span style=\"color: #333333;\">,<\/span>\r\n\t\t\t\tname<span style=\"color: #333333;\">,<\/span> score<span style=\"color: #333333;\">,<\/span> seat_number<span style=\"color: #333333;\">);<\/span>\r\n\r\n\t\tSystem<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span>details<span style=\"color: #333333;\">);<\/span>\t\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>Listing 1.4: Using the format method of the string class<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have previously covered:\u00a0The Number Class\u00a0and\u00a0\u00a0The Character Class. In this tutorial, we would examine the String class. I believe you understand these by now. If &hellip; <\/p>\n","protected":false},"author":395,"featured_media":106,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-99","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java-tutorial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java - The String Class - Java Tutorials<\/title>\n<meta name=\"description\" content=\"In this tutorial, we are going to cover the String wrapper class. We would examine: Creating new strings, formatting strings, concatenating strings and more\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java - The String Class - Java Tutorials\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, we are going to cover the String wrapper class. We would examine: Creating new strings, formatting strings, concatenating strings and more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/\" \/>\n<meta property=\"og:site_name\" content=\"Java Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2019-01-18T23:39:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-08-06T09:53:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/String-Class-in-Java.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"950\" \/>\n\t<meta property=\"og:image:height\" content=\"518\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\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:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/16-java-the-string-class\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/16-java-the-string-class\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"headline\":\"Java &#8211; The String Class\",\"datePublished\":\"2019-01-18T23:39:45+00:00\",\"dateModified\":\"2020-08-06T09:53:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/16-java-the-string-class\\\/\"},\"wordCount\":712,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/16-java-the-string-class\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/wp-content\\\/uploads\\\/sites\\\/9\\\/2019\\\/01\\\/String-Class-in-Java.jpg\",\"articleSection\":[\"Java Tutorial\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/16-java-the-string-class\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/16-java-the-string-class\\\/\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/16-java-the-string-class\\\/\",\"name\":\"Java - The String Class - Java Tutorials\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/16-java-the-string-class\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/16-java-the-string-class\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/wp-content\\\/uploads\\\/sites\\\/9\\\/2019\\\/01\\\/String-Class-in-Java.jpg\",\"datePublished\":\"2019-01-18T23:39:45+00:00\",\"dateModified\":\"2020-08-06T09:53:53+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"description\":\"In this tutorial, we are going to cover the String wrapper class. We would examine: Creating new strings, formatting strings, concatenating strings and more\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/16-java-the-string-class\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/16-java-the-string-class\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/16-java-the-string-class\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/wp-content\\\/uploads\\\/sites\\\/9\\\/2019\\\/01\\\/String-Class-in-Java.jpg\",\"contentUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/wp-content\\\/uploads\\\/sites\\\/9\\\/2019\\\/01\\\/String-Class-in-Java.jpg\",\"width\":950,\"height\":518,\"caption\":\"String class in Java\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/16-java-the-string-class\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java &#8211; The String Class\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#website\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/\",\"name\":\"Java Tutorials\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/author\\\/kindsonthegenius-2\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java - The String Class - Java Tutorials","description":"In this tutorial, we are going to cover the String wrapper class. We would examine: Creating new strings, formatting strings, concatenating strings and more","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/","og_locale":"en_US","og_type":"article","og_title":"Java - The String Class - Java Tutorials","og_description":"In this tutorial, we are going to cover the String wrapper class. We would examine: Creating new strings, formatting strings, concatenating strings and more","og_url":"https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/","og_site_name":"Java Tutorials","article_published_time":"2019-01-18T23:39:45+00:00","article_modified_time":"2020-08-06T09:53:53+00:00","og_image":[{"width":950,"height":518,"url":"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/String-Class-in-Java.jpg","type":"image\/jpeg"}],"author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/#article","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/www.kindsonthegenius.com\/java\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"headline":"Java &#8211; The String Class","datePublished":"2019-01-18T23:39:45+00:00","dateModified":"2020-08-06T09:53:53+00:00","mainEntityOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/"},"wordCount":712,"commentCount":0,"image":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/String-Class-in-Java.jpg","articleSection":["Java Tutorial"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/","url":"https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/","name":"Java - The String Class - Java Tutorials","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/#primaryimage"},"image":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/String-Class-in-Java.jpg","datePublished":"2019-01-18T23:39:45+00:00","dateModified":"2020-08-06T09:53:53+00:00","author":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"description":"In this tutorial, we are going to cover the String wrapper class. We would examine: Creating new strings, formatting strings, concatenating strings and more","breadcrumb":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/#primaryimage","url":"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/String-Class-in-Java.jpg","contentUrl":"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/String-Class-in-Java.jpg","width":950,"height":518,"caption":"String class in Java"},{"@type":"BreadcrumbList","@id":"https:\/\/www.kindsonthegenius.com\/java\/16-java-the-string-class\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.kindsonthegenius.com\/java\/"},{"@type":"ListItem","position":2,"name":"Java &#8211; The String Class"}]},{"@type":"WebSite","@id":"https:\/\/www.kindsonthegenius.com\/java\/#website","url":"https:\/\/www.kindsonthegenius.com\/java\/","name":"Java Tutorials","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.kindsonthegenius.com\/java\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.kindsonthegenius.com\/java\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/www.kindsonthegenius.com\/java\/author\/kindsonthegenius-2\/"}]}},"_links":{"self":[{"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/posts\/99","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/users\/395"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/comments?post=99"}],"version-history":[{"count":5,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/posts\/99\/revisions"}],"predecessor-version":[{"id":207,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/posts\/99\/revisions\/207"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/media\/106"}],"wp:attachment":[{"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/media?parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/categories?post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/tags?post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}