JAVA字符串格式化-String.format()的使用

JAVA字符串格式化-String.format()的使用

public class Test08 {
    public static void main(String[] args) {
        StringBuilder builder = new StringBuilder("select * from %s::%s");
        String tdwDB = "test";
        String tdwTable = "user";
        System.out.println( String.format(builder.toString(), tdwDB, tdwTable));
    }

运行结果

  public static void main(String[] args){
        final String TDW="abc_%s";
        String s="def";
        String tdwRtx = String.format(TDW, s);
        System.out.println(tdwRtx);
    }

在这里插入图片描述
更多内容String.format()的使用

posted @ 2019-05-31 18:32  smileLS66  阅读(87)  评论(0编辑  收藏  举报