@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菲"));
    }

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

推荐使用占位符

 

相关文章:

  • 2022-12-23
  • 2021-10-03
  • 2021-07-12
  • 2021-10-03
  • 2022-12-23
  • 2021-12-26
猜你喜欢
  • 2022-02-26
  • 2021-08-20
  • 2022-12-23
  • 2022-03-03
  • 2021-08-26
  • 2021-07-30
相关资源
相似解决方案