This Java program demonstrates how to concatenate two strings using the concat() method of the String class.
In this program, two strings "Tutor Joe's " and "Computer Educations" are assigned to the str1 and str2 variables, respectively. Then, the concat() method is called on str1 with str2 as an argument, and the result is stored in the str3 variable.
Finally, the concatenated string str3 is printed using the println() method.
public class Concat_TwoString { public static void main(String[] args) { String str1 = "Tutor Joe's "; String str2 = "Computer Educations"; System.out.println("String 1: " + str1); System.out.println("String 2: " + str2); String str3 = str1.concat(str2); System.out.println("Concatenated string: " + str3); } }
String 1: Tutor Joe's String 2: Computer Educations Concatenated string: Tutor Joe's Computer Educations
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions