How to parametrize a string and replace parameters
You can do this with MessageFormat
:
String userInput = "Showing {0} to {1} of {2}";
String result = MessageFormat.format(userInput, 1, 12, 30);
You can use String.format()
Here is how to do that
int a = 1;
int b = 12;
int c = 30;
String myFormattedString = String.format("Showing %d to %d of %d", a, b, c);
// Value of myFormattedString is 'Showing 1 to 12 of 30'