The connection is the way toward combining at least two little strings to from a greater string.
String link in java should be possible in four unique manners given underneath.
- Using + administrator
- Using concat() technique for String class
- Using attach() strategy for StringBuffer class
- Using attach() strategy for StringBuilder class
In beneath program, I have actualized these four techniques to link two strings.
In the event that you find anything missing or incorrect, at that point please notice it by commenting beneath.
Don’t hesitate to inquire as to whether you are getting any issue to comprehend the program
Program
class StringConcatenation
{
public static void main(String...s)
{
String s1="Hello",s2="World",s3,s4;
s3=s1+s2;
System.out.println(s3);
s4=s1.concat(s2);
System.out.println(s4);
StringBuffer s5=new StringBuffer().append(s1).append(s2);
System.out.println(s5);
StringBuilder s6=new StringBuilder().append(s1).append(s2);
System.out.println(s6);
}
}
Output