使用%s占位,使用String.format转换
public class Test { public static void main(String[] args) { String a1 = "a1"; String a2 = "a2"; String url = String.format("this is %s,this is %s", a1, a2); System.out.println(url); } }
控制台输出 this is a1,this is a2
this is a1,this is a2