1. 程式人生 > >格式化的幾種用法

格式化的幾種用法

{0} clas pri code body OS stat main world

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);

    }
}

格式化的幾種用法