{"id":19131,"date":"2020-07-07T03:44:48","date_gmt":"2020-07-07T10:44:48","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=19131"},"modified":"2023-12-01T03:39:21","modified_gmt":"2023-12-01T11:39:21","slug":"java-string","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/java-string\/","title":{"rendered":"Java String: A Guide for Beginners"},"content":{"rendered":"\n<p>When you think of string, you may see a cat playing around with a ball of yarn. It\u2019s true that a ball or yarn is string, but when programmers use the word string they mean something different.<br><\/p>\n\n\n\n<p>In programming, a string is a sequence of one or more characters. Given how important text-based data is to our everyday interactions with computers, it will come at no surprise that the string is a crucial part of programming.<br><\/p>\n\n\n\n<p>In this guide, we\u2019re going to discuss how to create a string, how to concatenate a string, and how to store the value of a string in a variable. We\u2019ll walk through a few examples to help guide you along the way.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating a Java String<\/h2>\n\n\n\n<p>A string is used to store text in Java. Whereas the <code>char<\/code> data type stores individual characters, strings can hold as many characters as you want. Strings are sequences of bytes.<br><\/p>\n\n\n\n<p>Strings are defined between double quotes. This is unlike languages like Python or JavaScript, which both accept both single and double quotes. Here&#8217;s an example of a string in Java:<br><\/p>\n\n\n\n<p><code>\u201cThis is an example string.\u201d<br><\/code><\/p>\n\n\n\n<p>You can print out the contents of a string using the <code>println()<\/code> function:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>System.out.println(\"This is an example string.\");<\/pre><\/div>\n\n\n\n<p>Our code returns: <code>This is an example string<\/code>. We\u2019ve constructed a new string. Now that you\u2019re aware of how to declare a string, we can talk about how to work with them in your code.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">String Concatenation<\/h2>\n\n\n\n<p>Concatenation, what a long word. It\u2019s definition is quite simple: it means combining two strings to create a new string. You can use the <code>+<\/code> operator (plus sign) to concatenate two strings.<br><\/p>\n\n\n\n<p>Let\u2019s say that we have two strings: William and Carter. The first string is a forename and the second string is a surname. We could combine them using the <code>+<\/code> operator:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>String fullname = \"William\" + \"Carter\";\nSystem.out.println(fullname);<\/pre><\/div>\n\n\n\n<p>Our code outputs: <code>WilliamCarter<\/code>. Wait, what happened? Why is there not a space between these two words?<br><\/p>\n\n\n\n<p>By default, there is no whitespace added between concatenated strings. If we want a space to appear, we&#8217;ll need to add it after the name <code>William<\/code>:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>String fullname = \"William \" + \"Carter\";\nSystem.out.println(fullname);<\/pre><\/div>\n\n\n\n<p>When we run our program, this is returned: <code>William Carter<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Calculating the Length of a String<\/h2>\n\n\n\n<p>How do you calculate the length of a string? What a good question. Luckily for us, we don\u2019t need to write any complex functions to do it.<br><\/p>\n\n\n\n<p>Java already has a built-in function that we can use to calculate the length of a string: <code>length()<\/code>. It&#8217;s a convenient name for a method!<br><\/p>\n\n\n\n<p>We\u2019re going to create a program that calculates the length of the names of two people in a fourth grade class. Create a new Java file and paste the following code into your main class:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>String name1 = \"William Carter\";\nString name2 = \"Helena Ohara\";\nint name1length = name1.length() - 1;\nint name2length = name2.length() - 1;\nSystem.out.println(name1 + \"'s name is \" + name1length + \" letters long.\");\nSystem.out.println(name2 + \"'s name is \" + name2length + \" letters long.\");<\/pre><\/div>\n\n\n\n<p>Let&#8217;s run our code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>William Carter's name is 13 letters long.\nHelena Ohara's name is 11 letters long.<\/pre><\/div>\n\n\n\n<p>We\u2019ve defined two variables which store our student&#8217;s names: name1 and name2. We\u2019ve then used the <code>length()<\/code> method to calculate the length of each of these strings. We subtracted 1 from each of the names\u2019 lengths to account for the space in the middle.<br><\/p>\n\n\n\n<p>Then, we printed out a message informing us of the length of each name.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Find a String within a String<\/h2>\n\n\n\n<p>There may be times when you want to find a string within another string. That&#8217;s where the <code>indexOf()<\/code> method comes in handy. This method returns the position of the first occurrence of a particular string of text within a string.<br><\/p>\n\n\n\n<p>Before we discuss how it works, we\u2019ll have to briefly talk about <code>index<\/code>. In Java, strings are indexed using index numbers. This means that every character in a string is assigned its own number, which we can use to access each item individually.<br><\/p>\n\n\n\n<p>Here&#8217;s a breakdown of the index within the string \u201cWilliam Carter\u201d:<br><\/p>\n\n\n\n<figure class=\"wp-block-table course-info-table\"><table><tbody><tr><td><strong>W<\/strong><\/td><td><strong>i<\/strong><\/td><td><strong>l<\/strong><\/td><td><strong>l<\/strong><\/td><td><strong>i<\/strong><\/td><td><strong>a<\/strong><\/td><td><strong>m<\/strong><\/td><td><br><\/td><td><strong>C<\/strong><\/td><td><strong>a<\/strong><\/td><td><strong>r<\/strong><\/td><td><strong>t<\/strong><\/td><td><strong>e<\/strong><\/td><td><strong>r<\/strong><\/td><\/tr><tr><td>0<\/td><td>1<\/td><td>2<\/td><td>3<\/td><td>4<\/td><td>5<\/td><td>6<\/td><td>7<\/td><td>8<\/td><td>9<\/td><td>10<\/td><td>11<\/td><td>12<\/td><td>13<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Notice that all characters in our string are assigned an index number, including whitespaces. In addition, notice how we start counting from 0. This is because strings are indexed starting at 0.<br><\/p>\n\n\n\n<p>Let\u2019s say we want to find out where the string <code>Carter<\/code> appears in this string. We could do so using the <code>indexOf()<\/code> method like this:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>String name = \"William Carter\";\nint position = name.indexOf(\"Carter\");\nSystem.out.println(\"Carter appears starting at index value \" + position);<\/pre><\/div>\n\n\n\n<p>Our code returns: Carter appears starting at index value 8. <code>indexOf()<\/code> returns the index position at which a character appears.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Check Whether Two Strings Are Equal<\/h2>\n\n\n\n<p>Comparing strings comes up all the time in programming. Think about when you enter a password into a login form. What does the application do? It compares the password you have entered with the one the application has stored in its database.<br><\/p>\n\n\n\n<p>Let\u2019s say that we want to write a program that checks whether a user\u2019s password is correct. Open up a new Java file and paste in the following code into your main program:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>String entered_password = \"Test123\";\nString saved_password = \"Test12345\";\nboolean compare_passwords = entered_password.equals(saved_password);\nSystem.out.println(\"Does the entered password match the saved password? \" + compare_passwords);<\/pre><\/div>\n\n\n\n<p>Our code returns:<br><\/p>\n\n\n\n<p>Does the entered password match the saved password? false<br><\/p>\n\n\n\n<p>Our program checks to see whether the two strings we have specified \u2013 <code>entered_password<\/code> and <code>saved_password<\/code> are equal. We use the <code>equals() <\/code>method to perform this check. This method returns true if the strings are equal; otherwise, it returns false.<br><\/p>\n\n\n\n<p>Let\u2019s change the value of <code>entered_password<\/code> to be equal to <code>saved_password<\/code>:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>String entered_password = \"Test12345\";\nString saved_password = \"Test12345\";\n...<\/pre><\/div>\n\n\n\n<p>When we run this code, our program returns:<br><\/p>\n\n\n\n<p>Does the entered password match the saved password? true<br><\/p>\n\n\n\n<p>Both the strings we have specified match, which means that our <code>equals()<\/code> method evaluates to true.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Special Characters<\/h2>\n\n\n\n<p>Strings must be written within double quotes. This sounds like no big deal until you want to include a double quote in your program. This will return an error.<br><\/p>\n\n\n\n<p>The way to resolve this error is to use the backslash (\\) character. This will turn any character that immediately follows the string into a special character. Consider this example:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>String statement = \"Your order for \\\"Chocolate Chip Cookie x2\\\" was processed.\";<\/pre><\/div>\n\n\n\n<p>This string will work in our program because we\u2019ve specified a backslash before each of the double quotes in our string. This string returns: Your order for Chocolate Chip Cookie x2 was processed.<br><\/p>\n\n\n\n<p>Now we&#8217;ve got another problem: what if you want to use a backslash in your string? To do so, you can write two backslashes side-by-side:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>String order_reference = \"Your order reference is 202\\\\303.\"<\/pre><\/div>\n\n\n\n<p>This returns the string: <code>Your order reference is 202\\303.\"<\/code><br><\/p>\n\n\n\n<p>There are a number of other special characters that you can use in Java. One of the most useful that you\u2019ll encounter is one called \\n, or new line. This character creates a new line in a string:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>String order_reference = \"Your order reference is: \\n 202\\\\303.\"<\/pre><\/div>\n\n\n\n<p>Our string is equal to:<br><\/p>\n\n\n\n<p>Your order reference is:<\/p>\n\n\n\n<p><code>202\\303<\/code><\/p>\n\n\n\n<p>The string has been split up onto two lines because we specified a new line character after the <code>is:<\/code>  part of our string.<\/p>\n\n\n\n<iframe loading=\"lazy\" frameborder=\"0\" width=\"100%\" height=\"400px\" src=\"https:\/\/repl.it\/@careerkarma\/Java-Strings?lite=true\"><\/iframe>\n<br>\n<br>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Strings allow you to work with text-based data in your programs. A string can hold any number of characters, including no characters at all.<br><\/p>\n\n\n\n<p>Using string methods such as <code>indexOf()<\/code> and <code>equals()<\/code>, you can manipulate the contents of a string in Java. Now you\u2019re ready to start working with strings in Java like an expert!<\/p>\n","protected":false},"excerpt":{"rendered":"When you think of string, you may see a cat playing around with a ball of yarn. It\u2019s true that a ball or yarn is string, but when programmers use the word string they mean something different. In programming, a string is a sequence of one or more characters. Given how important text-based data is&hellip;","protected":false},"author":240,"featured_media":19133,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17289],"tags":[],"class_list":{"0":"post-19131","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-java"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Java","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":"","is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Java String: A Guide for Beginners | Career Karma<\/title>\n<meta name=\"description\" content=\"Strings store text-based data in Java. On Career Karma, learn how to declare and work with strings in your Java code.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/java-string\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java String: A Guide for Beginners\" \/>\n<meta property=\"og:description\" content=\"Strings store text-based data in Java. On Career Karma, learn how to declare and work with strings in your Java code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/java-string\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-07T10:44:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T11:39:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/jantine-doornbos-xt9tb6oa42o-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"667\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\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:\/\/careerkarma.com\/blog\/java-string\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-string\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Java String: A Guide for Beginners\",\"datePublished\":\"2020-07-07T10:44:48+00:00\",\"dateModified\":\"2023-12-01T11:39:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-string\/\"},\"wordCount\":1119,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-string\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/jantine-doornbos-xt9tb6oa42o-unsplash.jpg\",\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/java-string\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/java-string\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/java-string\/\",\"name\":\"Java String: A Guide for Beginners | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-string\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-string\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/jantine-doornbos-xt9tb6oa42o-unsplash.jpg\",\"datePublished\":\"2020-07-07T10:44:48+00:00\",\"dateModified\":\"2023-12-01T11:39:21+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"Strings store text-based data in Java. On Career Karma, learn how to declare and work with strings in your Java code.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-string\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/java-string\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/java-string\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/jantine-doornbos-xt9tb6oa42o-unsplash.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/jantine-doornbos-xt9tb6oa42o-unsplash.jpg\",\"width\":1000,\"height\":667},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/java-string\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\/\/careerkarma.com\/blog\/java\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Java String: A Guide for Beginners\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Java String: A Guide for Beginners | Career Karma","description":"Strings store text-based data in Java. On Career Karma, learn how to declare and work with strings in your Java code.","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:\/\/careerkarma.com\/blog\/java-string\/","og_locale":"en_US","og_type":"article","og_title":"Java String: A Guide for Beginners","og_description":"Strings store text-based data in Java. On Career Karma, learn how to declare and work with strings in your Java code.","og_url":"https:\/\/careerkarma.com\/blog\/java-string\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-07-07T10:44:48+00:00","article_modified_time":"2023-12-01T11:39:21+00:00","og_image":[{"width":1000,"height":667,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/jantine-doornbos-xt9tb6oa42o-unsplash.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/java-string\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/java-string\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Java String: A Guide for Beginners","datePublished":"2020-07-07T10:44:48+00:00","dateModified":"2023-12-01T11:39:21+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-string\/"},"wordCount":1119,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-string\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/jantine-doornbos-xt9tb6oa42o-unsplash.jpg","articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/java-string\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/java-string\/","url":"https:\/\/careerkarma.com\/blog\/java-string\/","name":"Java String: A Guide for Beginners | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-string\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-string\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/jantine-doornbos-xt9tb6oa42o-unsplash.jpg","datePublished":"2020-07-07T10:44:48+00:00","dateModified":"2023-12-01T11:39:21+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"Strings store text-based data in Java. On Career Karma, learn how to declare and work with strings in your Java code.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/java-string\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/java-string\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/java-string\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/jantine-doornbos-xt9tb6oa42o-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/jantine-doornbos-xt9tb6oa42o-unsplash.jpg","width":1000,"height":667},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/java-string\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/careerkarma.com\/blog\/java\/"},{"@type":"ListItem","position":3,"name":"Java String: A Guide for Beginners"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/19131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=19131"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/19131\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/19133"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=19131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=19131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=19131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}