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);


    
2

1 Answer 1

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);
Sign up to request clarification or add additional context in comments.

1 Comment

A more direct equivalent of Console.WriteLine would be System.out.printf(...)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.