Program for String Concatenation in Java

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.

  1. Using + administrator
  2. Using concat() technique for String class
  3. Using attach() strategy for StringBuffer class
  4. 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

Program for String Concatenation in Java

Leave a Comment

error: Alert: Content is protected!!