JAVA 占位符%s的使用

使用%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

posted @ 2021-12-29 19:48  还可入梦  阅读(1349)  评论(0编辑  收藏  举报