字符串替换格式

import java.text.MessageFormat;

public class StrFormat {
    public static void main(String[] args) {
        String str1 = "今天你签到了吗? {0}老师提醒你,记得及时{1}哦";    
        String name = "张三";        
        String type = "签到";    
        String message = MessageFormat.format(str1, name,type);         
        System.out.println(message);     
    }
}

输出: 今天你签到了吗? 张三老师提醒你,记得及时签到哦

原文地址:https://www.cnblogs.com/z360519549/p/11542473.html