zoukankan      html  css  js  c++  java
  • 字符串用占位符拼接 String ms = MessageFormat.format("{0,number,#.##}", 3.656);

    public class Test {
    public static void main(String[] args) {
    String newContent = " private String {0}; " +
    " private boolean modify_{0} = false; " +
    " " +
    " public String {1}() '{' " +
    " return {0}; " +
    " '}' " +
    " " +
    " public void setBDCDYID(String {0}) '{' " +
    " if (this.{0} != {0}) '{' " +
    " this.{0} = {0}; " +
    " modify_{0} = true; " +
    " '}' " +
    " '}'";
    String dd = MessageFormat.format(newContent,"bdcdyic","setBdcdyid");
    System.out.println(dd);
        //特殊符号{ } 需要用左右单引号围起来 '{' '}',否则和占位符冲突
    System.out.println(MessageFormat.format("{1} '{' '}' hello {0} {1}","world","lili"));
    }

    private String id;
    public void setId(String id){
    this.id = id;
    }
    }

    第二个参数可选。

    String ms = MessageFormat.format("{0,number,#.##}", 3.656);

    若格式不匹配则报异常  如第二个参数限制为数值  但内容为 String

    参考 https://blog.csdn.net/Mr_Tony/article/details/50175447?utm_source=blogxgwz9

  • 相关阅读:
    短信验证倒计时60s
    jquery select省市区三级联动
    C# 遍历文本框
    html formData 数据 提交和 .netMVC接收
    jq遍历table 下的 td 添加类
    jq 替换DOM layeui 不刷新
    jq 获取表单所有数据
    js 二级联动
    MVC 下载文件
    MVC 上传文件
  • 原文地址:https://www.cnblogs.com/shihx/p/13462412.html
Copyright © 2011-2022 走看看