String 类对象 只能使用 % 有效
MessageFormat 类对象 只能使用 {} 有效
package demo;
import java.text.MessageFormat;
public class Test {
public static void main(String[] args) throws Exception {
System.out.println(String.format("Input = {0} and Output = {1}", 1,2));
System.out.println(MessageFormat.format("Input = {0} and Output = {1}", 1,2));
System.out.println();
System.out.println(String.format("Input = %d and Output = %d", 1,2));
System.out.println(MessageFormat.format("Input = %d and Output = %d", 1,2));
}
}