String append with format in android

android, string

Solution

Use StringBuilder or StringBuffer but with adequate initial capacity to avoid re-allocation. The default capacity is 16, so once you exceed that, the data has to be copied into a new bigger place. Use append not +.

int integer = 5;

StringBuilder s = new StringBuilder(100);
 s.append("something");
 s.append(integer);
 s.append("more text");

Problem

Anybody help me please. I don't know how to append the String with format in android similar to this: ``` String key = ""; append("%d-%d-%d", 0, 1, 2)); ``` Please give me an example. Thank you in advance.

Original source