{"id":1909,"date":"2022-09-12T19:23:53","date_gmt":"2022-09-12T19:23:53","guid":{"rendered":"https:\/\/gyanipandit.com\/programming\/?p=1909"},"modified":"2022-09-12T19:23:55","modified_gmt":"2022-09-12T19:23:55","slug":"java-string-concat","status":"publish","type":"post","link":"https:\/\/gyanipandit.com\/programming\/java-string-concat\/","title":{"rendered":"Java String Concat Method"},"content":{"rendered":"<p style=\"text-align: center;\"><strong>Java String Concat Method<\/strong><\/p>\n\n\n<p>With this method, we can concatenate one string at the end of another string. This is like saying \u2013 hey&#8230; take this string, and glue it at the end of the given string. We can also perform concatenation of the strings using the + operator with the strings. So, let&#8217;s try using both, the Concat method and the + operator as well, in the following program \u2192<\/p>\n\n\n\n<p class=\"has-background-color has-foreground-background-color has-text-color has-background\">public class StringMethods {<br>public static void main(String[] args) {<br>String str1 = &#8220;Hello&#8221;;<br>String str2 = &#8220;Java&#8221;;<br>String str3 = str1.concat(str2);<br>System.out.println(str3);<br>}<br>}<\/p>\n\n\n\n<p>So, in the above program, str1.concat(str2) means we are concatenating the string literal whose reference is str2, at the end of string literal whose reference is str1. So, this is like &#8221;Hello&#8221; + &#8221;Java&#8221;, and the result is &#8221;HelloJava&#8221;. This is interesting. Also, now let&#8217;s try doing the same thing with + operator.<\/p>\n\n\n\n<p class=\"has-background-color has-foreground-background-color has-text-color has-background\">public class StringMethods {<br>public static void main(String[] args) {<br>String str1 = &#8220;Hello&#8221;;<br>String str2 = &#8220;Java&#8221;;<br>String str3 = str1 + str2;<br>System.out.println(str3);<br>}<br>}<\/p>\n\n\n\n<p>So, if we try executing the above program, there is no change in the output. But just wanted to mention that we can do the concatenation with the + operator.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java String Concat Method With this method, we can concatenate one string at the end of another string. This is like saying \u2013 hey&#8230; take this string, and glue it at the end of the given string. We can also perform concatenation of the strings using the + operator with the strings. So, let&#8217;s try [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[12,11],"class_list":{"0":"post-1909","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-java-tutorial","7":"tag-java","8":"tag-java-tutorial"},"_links":{"self":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/1909","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/comments?post=1909"}],"version-history":[{"count":2,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/1909\/revisions"}],"predecessor-version":[{"id":3000,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/1909\/revisions\/3000"}],"wp:attachment":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/media?parent=1909"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/categories?post=1909"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/tags?post=1909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}