在Java中使用MessageFormat类在字符串中传递不同的变量
System.out.println(MessageFormat.format("I want to resolve this statement "{ {0}, {1} }", "this", "this")); 当你打印它时,它将显示--> { {0},{1} },并且不会解析带有值的参数,因为它用大括号括起来。
发布于 2017-05-26 13:58:02
你想要的是:
System.out.println(MessageFormat.format("I want to resolve this statement '{'{0}, {1}'}'", "this", "this"));输出
我想解决这个语句{ this,this}
发布于 2017-05-26 14:09:41
请按如下所示更改字符串-
System.out.println(MessageFormat.format("I want to resolve this statement {0}, {1}", "this", "this"));现在,输出将为-
I want to resolve this statement this, this
将使用参数转换大括号
发布于 2017-05-26 13:51:29
我正面临着这个问题,我想和更多的人分享。因此,为了解决相同问题,请用单引号将其括起来:
"{ '{0}','{1}‘}“
https://stackoverflow.com/questions/44194497
复制相似问题