例:String con=String.format("我想要使用/'%s/' ,这样很/%s/ 吧!",new Object[]{"占位符","简单"})//两参数:1.字符串2.填充字符串占位符的集合
输出结果:我想要使用'占位符',这样很简单吧! 要点:/'%s/' 为字符串的占位符 String msg=String.format("我今年%d 岁了.",new Object[]{new Integer(20)}); 输出结果:我今年20岁了. 要点%d为Integer的占位符(注意:2参数是一个Object集合) |