转义java String.format中的格式化字符 [英] escaping formatting characters in java String.format

查看:693
本文介绍了转义java String.format中的格式化字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题几乎与这个问题相同.Net问题 exept for java。

This question is pretty much the same as this .Net question exept for java.

如何转义java string.format中的%1 $字符?

How do you escape the %1$ characters in a java string.format?

我需要这样做的原因是我正在构建一个字符串,以后会有更多信息插入其中。我曾经想过让其中一个args只是%1 $,但这似乎不是很优雅?

THe reason I need to do this is that I'm building up a string that will later have more info inserted into it. I've thought of having one of the args just be "%1$" but that doesn't seem to be very elegant?

抱歉,如果这很明显我的java生气了。

sorry if this is obvious my java is a tad rusty.

推荐答案

你可以加倍%

这篇关于转义java String.format中的格式化字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆