Answers for "concat int and string in java"

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
0

java concatenate string and int

String s1 = "My favourite number is ";
int n = 5;
String s2 = s1 + 5; 
//s2 is "My favourite number is 5"
Posted by: Guest on July-28-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language