Answers for "best way to concatenate strings in java"

12

String concatenation in java

// String concatenation in java using concat() method
public class StringConcatMethodDemo
{
   public static void main(String[] args)
   {
      String str1 = "Flower ";
      String str2 = "Brackets";
      String str3 = str1.concat(str2);
      System.out.println(str3);
   }
}
Posted by: Guest on December-08-2020
4

string concat in java

public class ConcatenationExample {
   public static void main(String args[]) {
       //One way of doing concatenation
       String str1 = "Welcome";
       str1 = str1.concat(" to ");
       str1 = str1.concat(" String handling ");
       System.out.println(str1);

       //Other way of doing concatenation in one line
       String str2 = "This";
       str2 = str2.concat(" is").concat(" just a").concat(" String");
       System.out.println(str2);
   }
}
Posted by: Guest on November-07-2020
6

java concatenate strings

public class Concat {
    String cat(String a, String b) {
        a += b;
        return a;
    }
}
Posted by: Guest on June-29-2020
0

string concatenation in java

String s="Sachin"+" Tendulkar";  
   System.out.println(s);//Sachin Tendulkar  

Output:Sachin Tendulkar
Posted by: Guest on June-15-2021
0

how do you combine 2 strings in java

-By  using (+) operator
-By  using concatenate method (concat()).
                      String strconcat3=strconcat2.concat(strconcat);

-By StringBuffer
-String strconcat= new StringBuilder().append("matt")
                                .append("damon").toString();
                                
-By StringBuilder
- String strconcat2= new StringBuffer()
                  .append("matt").append("damon").toString();
Posted by: Guest on January-14-2021

Code answers related to "best way to concatenate strings in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language