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()的使用

原文地址:https://www.cnblogs.com/szls-666/p/12494188.html