0

How insert (a) and (b) in string line in java?

string a = "David";
string b= "Mike";
Console.WriteLine("This is test for {0} and {1}",a,b);


    
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Reza BMN
  • 11
  • 1

1 Answers1

1

You are looking for something called "String Interpolation". Since Java 5 you can use this:

String s = String.format("This is test for %s and %s", a, b);
Plexian
  • 58
  • 1
  • 5