java 占位符

    @Test
    void contextLoads() {
        String s1 = "你好{0}, 我叫{1}";
        System.out.println(MessageFormat.format(s1, "张飞", "王菲"));

        String s2 = "你好%s, 我叫%s";
        System.out.println(String.format(s2, "张1飞", "王1菲"));
    }

字符串可以直接拼接,也可以使用占位符

推荐使用占位符

原文地址:https://www.cnblogs.com/wt7018/p/13363539.html