格式化的几种用法

String.format详情参考地址

public class FormatWay {
   static final String detail_url = "http://www.example.com?local={0}";
    public static void main(String[] args) {
        String val = String.format("%s:%s", "hello", "world");
        String detailUrl = MessageFormat.format(detail_url, "hello");
        System.out.println(val);
        System.out.println(detailUrl);

    }
}
posted @ 2018-03-31 12:22  姩澕  阅读(150)  评论(0编辑  收藏  举报