{"id":119712,"date":"2023-09-07T08:14:08","date_gmt":"2023-09-07T05:14:08","guid":{"rendered":"https:\/\/examples.javacodegeeks.com\/?p=119712"},"modified":"2023-09-07T08:14:09","modified_gmt":"2023-09-07T05:14:09","slug":"java-string-concatenation-methods","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/","title":{"rendered":"Java String Concatenation Methods"},"content":{"rendered":"<p>In Java, <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/lang\/String.html\" target=\"_blank\" rel=\"noopener\">String<\/a> concatenation refers to the process of combining multiple strings into a single string. Let us explore various Java string concatenation methods.<\/p>\n<h2><a name=\"introduction\"><\/a>1. Introduction<\/h2>\n<h3>1.1 Immutable String Concatenation<\/h3>\n<p>In Java, strings are immutable, which means that once a string object is created, it cannot be changed. When you perform concatenation on strings using immutable operations, you create new string objects to hold the combined content. This approach has some advantages and disadvantages:<\/p>\n<h4>1.1.1 Advantages<\/h4>\n<ul>\n<li>Safety: Immutable strings are thread-safe because they cannot be modified once created, which helps prevent data corruption in multi-threaded applications.<\/li>\n<li>Predictable: Immutable strings ensure that the original string values remain unchanged, making it easier to reason about code.<\/li>\n<\/ul>\n<h4>1.1.2 Disadvantages<\/h4>\n<ul>\n<li>Performance: Immutable concatenation can be inefficient for large-scale concatenations or in loops because it creates a new string object each time, resulting in unnecessary memory overhead.<\/li>\n<li>Complexity: Code that performs a lot of string concatenation using the + operator, concat(), etc. method may lead to performance bottlenecks.<\/li>\n<\/ul>\n<h3>1.2 Mutable String Concatenation<\/h3>\n<p>To address the performance drawbacks of immutable concatenation, Java provides mutable alternatives like <code>StringBuilder<\/code> and <code>StringBuffer<\/code>. These classes allow you to modify the content of a string without creating a new object each time you perform concatenation. The primary difference between them is that <code>StringBuilder<\/code> is not thread-safe (not synchronized), while <code>StringBuffer<\/code> is thread-safe (synchronized)<\/p>\n<h4>1.2.1 Advantages<\/h4>\n<ul>\n<li>Performance: Mutable concatenation is more efficient, especially for large-scale or iterative concatenations, as it avoids creating unnecessary string objects.<\/li>\n<li>Flexibility: You can easily modify the content of a mutable string during operations.<\/li>\n<\/ul>\n<h4>1.2.2 Disadvantages<\/h4>\n<ul>\n<li>Thread-safety: <code>StringBuilder<\/code> is not thread-safe, so you need to synchronize access explicitly if used in a multi-threaded context.<\/li>\n<\/ul>\n<h2>2. Immutable String Concatenation<\/h2>\n<p>Immutable String Concatenation in Java involves combining multiple strings into a new string without modifying the original strings. Java strings are immutable, meaning that once a string is created, it cannot be changed. Therefore, when you perform concatenation using immutable operations, you create new string objects to hold the combined content. This approach ensures that the original strings remain unchanged. Here&#8217;s a detailed explanation of five common methods for immutable string concatenation in Java:<\/p>\n<h3>2.1 Using Addition (+) Operator<\/h3>\n<p>The <code>+<\/code> operator is one of the most common ways to concatenate strings in Java. When you use the <code>+<\/code> operator with strings, Java automatically converts the operands to strings and combines them into a new string.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Snippet<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">String str1 = \"Hello, \";\nString str2 = \"world!\";\nString result = str1 + str2; \/\/ Creates a new string object\nSystem.out.println(result); \/\/ Output: Hello, world!\n<\/pre>\n<h3>2.2 Using concat() Method<\/h3>\n<p>The <code>concat()<\/code> method is provided by the <code>String<\/code> class for string concatenation. It creates a new string by appending the argument string to the end of the original string.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Snippet<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">String str1 = \"Hello, \";\nString str2 = \"world!\";\nString result = str1.concat(str2); \/\/ Creates a new string object\nSystem.out.println(result); \/\/ Output: Hello, world!\n<\/pre>\n<h3>2.3 Using String.join() Method<\/h3>\n<p>The <code>String.join()<\/code> method is used to concatenate multiple strings with a delimiter. It takes an iterable of strings and joins them using the specified delimiter.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><span style=\"text-decoration: underline\"><em>Snippet<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">String[] words = {\"Hello\", \"world\"};\nString result = String.join(\", \", words); \/\/ Creates a new string object\nSystem.out.println(result); \/\/ Output: Hello, world\n<\/pre>\n<h3>2.4 Using String.format() Method<\/h3>\n<p>The <code>String.format()<\/code> method allows you to create formatted strings by specifying a format string and supplying the values to be inserted into the format placeholders.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Snippet<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">String name = \"Alice\";\nint age = 30;\nString message = String.format(\"My name is %s, and I am %d years old.\", name, age); \/\/ Creates a new string object\nSystem.out.println(message); \/\/ Output: My name is Alice, and I am 30 years old.\n<\/pre>\n<h3>2.5 Using Java Stream API<\/h3>\n<p>You can use the Java Stream API to concatenate strings from a collection or array. Here&#8217;s an example using a list of strings:<\/p>\n<p><span style=\"text-decoration: underline\"><em>Snippet<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">List&lt;String&gt; words = Arrays.asList(\"Hello\", \"world\");\nString result = words.stream().collect(Collectors.joining(\", \")); \/\/ Creates a new string object\nSystem.out.println(result); \/\/ Output: Hello, world\n<\/pre>\n<p>In all these examples, the original strings (<code>str1<\/code>, <code>str2<\/code>, <code>words<\/code>, etc.) remain unchanged, and new string objects are created to hold the concatenated result. Immutable string concatenation is safe, predictable, and suitable for most string manipulation scenarios. However, for extensive or performance-critical concatenations, consider using mutable alternatives like <code>StringBuilder<\/code> or <code>StringBuffer<\/code> to avoid unnecessary object creation.<\/p>\n<h2>3. Immutable String Concatenation Comparison<\/h2>\n<table>\n<tbody>\n<tr>\n<th>Method<\/th>\n<th>Performance<\/th>\n<th>Memory Usage<\/th>\n<\/tr>\n<tr>\n<td>Using Addition (+) Operator<\/td>\n<td>May be inefficient for large-scale concatenations or loops due to frequent object creation.<\/td>\n<td>Higher memory usage as it creates new string objects for each concatenation operation.<\/td>\n<\/tr>\n<tr>\n<td>Using concat() Method<\/td>\n<td>Similar to the + operator, it may be inefficient for large-scale concatenations.<\/td>\n<td>Higher memory usage as it creates new string objects for each concatenation operation.<\/td>\n<\/tr>\n<tr>\n<td>Using String.join() Method<\/td>\n<td>Generally efficient for joining strings with a delimiter.<\/td>\n<td>Memory-efficient as it minimizes unnecessary string object creation.<\/td>\n<\/tr>\n<tr>\n<td>Using String.format() Method<\/td>\n<td>Efficient for creating formatted strings, especially for complex formatting.<\/td>\n<td>Higher memory usage due to the creation of formatted string objects.<\/td>\n<\/tr>\n<tr>\n<td>Using Java Stream API<\/td>\n<td>Efficient for joining strings from collections or arrays.<\/td>\n<td>Memory-efficient as it avoids creating intermediate string objects.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>4. Mutable String Concatenation<\/h2>\n<p>Mutable string concatenation in Java involves the process of efficiently combining multiple strings into a single string while allowing modifications to the content during the concatenation process. Unlike immutable string concatenation, where new string objects are created for each concatenation, mutable concatenation is performed using classes like <code>StringBuffer<\/code>, <code>StringBuilder<\/code>, and <code>StringJoiner<\/code>, which provide mutable string manipulation capabilities. Let&#8217;s delve into each of these topics in detail with examples:<\/p>\n<h3>4.1 Using StringBuffer<\/h3>\n<p><code>StringBuffer<\/code> is a class in Java that provides mutable string manipulation and is thread-safe (synchronized). It is suitable for scenarios where thread safety is a concern, but it may be slightly slower than <code>StringBuilder<\/code> due to synchronization.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Snippet<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">StringBuffer stringBuffer = new StringBuffer();\nstringBuffer.append(\"Hello, \");\nstringBuffer.append(\"world!\");\nString result = stringBuffer.toString(); \/\/ Convert StringBuffer to a string\nSystem.out.println(result); \/\/ Output: Hello, world!\n<\/pre>\n<h3>4.2 Using StringBuilder<\/h3>\n<p><code>StringBuilder<\/code> is similar to <code>StringBuffer<\/code> but is not thread-safe. It is more efficient than <code>StringBuffer<\/code> in single-threaded scenarios because it does not incur the synchronization overhead.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Snippet<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">StringBuilder stringBuilder = new StringBuilder();\nstringBuilder.append(\"Hello, \");\nstringBuilder.append(\"world!\");\nString result = stringBuilder.toString(); \/\/ Convert StringBuilder to a string\nSystem.out.println(result); \/\/ Output: Hello, world!\n<\/pre>\n<p>In practice, <code>StringBuilder<\/code> is often preferred over <code>StringBuffer<\/code> unless you specifically need thread safety.<\/p>\n<h3>4.3 Using StringJoiner<\/h3>\n<p><code>StringJoiner<\/code> is a class introduced in Java 8 that provides a way to join strings with a delimiter and an optional prefix and suffix. It is especially useful when you want to concatenate elements from collections or arrays.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Snippet<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false;\">StringJoiner joiner = new StringJoiner(\", \", \"Names: [\", \"]\");\njoiner.add(\"Alice\");\njoiner.add(\"Bob\");\njoiner.add(\"Charlie\");\nString result = joiner.toString();\nSystem.out.println(result); \/\/ Output: Names: [Alice, Bob, Charlie]\n<\/pre>\n<p>In this example, <code>StringJoiner<\/code> allows you to join names with a comma and enclose them in square brackets.<\/p>\n<p>In summary, mutable string concatenation in Java is a powerful technique that allows you to efficiently concatenate and modify strings. The choice between <code>StringBuilder<\/code>, <code>StringBuffer<\/code>, and <code>StringJoiner<\/code> depends on factors such as performance requirements and the need for thread safety in your application.<\/p>\n<h2>5. Mutable String Concatenation Comparison<\/h2>\n<table>\n<tbody>\n<tr>\n<th>Method<\/th>\n<th>Performance<\/th>\n<th>Memory Usage<\/th>\n<th>Thread Safety<\/th>\n<\/tr>\n<tr>\n<td>Using StringBuffer<\/td>\n<td>Efficient for single-threaded scenarios, slightly slower due to synchronization.<\/td>\n<td>Higher memory usage due to synchronization overhead.<\/td>\n<td>Thread-safe (synchronized).<\/td>\n<\/tr>\n<tr>\n<td>Using StringBuilder<\/td>\n<td>Most efficient for single-threaded scenarios due to no synchronization overhead.<\/td>\n<td>Lower memory usage compared to StringBuffer.<\/td>\n<td>Not thread-safe.<\/td>\n<\/tr>\n<tr>\n<td>Using StringJoiner<\/td>\n<td>Efficient for joining elements from collections or arrays.<\/td>\n<td>Memory is efficient, as it avoids unnecessary object creation.<\/td>\n<td>Not thread-safe; primarily used for joining strings with a delimiter.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>6. Conclusion<\/h2>\n<p>In the realm of Java string manipulation, the choice between immutable and mutable concatenation techniques holds significant implications for code efficiency and functionality.<\/p>\n<p>Immutable string concatenation is achieved through methods like the <code>+<\/code> operator and <code>concat()<\/code>, which can be less efficient for extensive operations, leading to higher memory usage and slower execution due to the creation of numerous new string objects. However, it excels in ensuring thread safety and preserving string immutability.<\/p>\n<p>On the other hand, mutable concatenation with <code>StringBuffer<\/code> or, preferably, <code>StringBuilder<\/code> is notably more efficient, especially in single-threaded applications, as it minimizes memory overhead by allowing in-place modifications. This approach offers superior performance and memory control, making it well-suited for tasks involving large or complex strings and extensive manipulations.<\/p>\n<p>Additionally, <code>StringJoiner<\/code> provides an efficient and structured method for joining strings from collections or arrays. Ultimately, the choice between these techniques hinges on specific use cases, with immutable concatenation favoring thread safety and simplicity, and mutable concatenation or <code>StringJoiner<\/code> tailored for performance-critical tasks and memory efficiency.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Java, String concatenation refers to the process of combining multiple strings into a single string. Let us explore various Java string concatenation methods. 1. Introduction 1.1 Immutable String Concatenation In Java, strings are immutable, which means that once a string object is created, it cannot be changed. When you perform concatenation on strings using &hellip;<\/p>\n","protected":false},"author":119,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[189,478,212,241,242,1103],"class_list":["post-119712","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-core-java","tag-core-java-2","tag-java","tag-java-basics-2","tag-string-2","tag-stringbuffer-2","tag-stringbuilder"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java String Concatenation Methods - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Explore various Java string concatenation methods, analyzing code syntax, comparing their performance and memory usage.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java String Concatenation Methods - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Explore various Java string concatenation methods, analyzing code syntax, comparing their performance and memory usage.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2023-09-07T05:14:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-07T05:14:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/\"},\"author\":{\"name\":\"Yatin\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\"},\"headline\":\"Java String Concatenation Methods\",\"datePublished\":\"2023-09-07T05:14:08+00:00\",\"dateModified\":\"2023-09-07T05:14:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/\"},\"wordCount\":1163,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"keywords\":[\"core java\",\"Java\",\"java basics\",\"string\",\"stringbuffer\",\"StringBuilder\"],\"articleSection\":[\"Core Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/\",\"name\":\"Java String Concatenation Methods - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2023-09-07T05:14:08+00:00\",\"dateModified\":\"2023-09-07T05:14:09+00:00\",\"description\":\"Explore various Java string concatenation methods, analyzing code syntax, comparing their performance and memory usage.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Java String Concatenation Methods\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\",\"name\":\"Yatin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"caption\":\"Yatin\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\/\/www.javacodegeeks.com\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java String Concatenation Methods - Java Code Geeks","description":"Explore various Java string concatenation methods, analyzing code syntax, comparing their performance and memory usage.","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:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/","og_locale":"en_US","og_type":"article","og_title":"Java String Concatenation Methods - Java Code Geeks","og_description":"Explore various Java string concatenation methods, analyzing code syntax, comparing their performance and memory usage.","og_url":"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2023-09-07T05:14:08+00:00","article_modified_time":"2023-09-07T05:14:09+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Yatin","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/"},"author":{"name":"Yatin","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13"},"headline":"Java String Concatenation Methods","datePublished":"2023-09-07T05:14:08+00:00","dateModified":"2023-09-07T05:14:09+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/"},"wordCount":1163,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","keywords":["core java","Java","java basics","string","stringbuffer","StringBuilder"],"articleSection":["Core Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/","url":"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/","name":"Java String Concatenation Methods - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2023-09-07T05:14:08+00:00","dateModified":"2023-09-07T05:14:09+00:00","description":"Explore various Java string concatenation methods, analyzing code syntax, comparing their performance and memory usage.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-string-concatenation-methods\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"Java String Concatenation Methods"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13","name":"Yatin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","caption":"Yatin"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/119712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/119"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=119712"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/119712\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=119712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=119712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=119712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}