我以前用Java做过这个,但我记不清具体是怎么做的了。
您可以创建一个字符串:
String foo = "She %s sea shells by the seashore.";然后,您可以在字符串中写入单词"sells“。
你用什么来做这个呢?
发布于 2011-07-27 23:22:32
String myString = "sells";
String foo = String.format("She %s sea shells by the seashore.", myString);发布于 2011-07-27 23:22:00
您要查找的是Formatter class或String.format convenience method
String.format(foo, "sells");发布于 2011-07-27 23:23:07
String.format?
Object a[] = { "Real's HowTo", "http://www.any.com" ,
java.util.Calendar.getInstance()};
String s = String.format("Welcome %1$s at %2$s ( %3$tY %3$tm %3$te )", a);
System.out.println(s);
// output : Welcome Real's HowTo at http://www.any.com (2010 06 26)https://stackoverflow.com/questions/6846855
复制相似问题