I have a constant declared as following:
protected static final String LOC_RC_ELT = "[id*='rcLine'][id$='paxIndex{0}']";
And then I use MessageFormat:
MessageFormat.format(LOC_RC_ELT, paxIndex)
In this case MessageFormat fails to format the string declared as constant:
This is not true for other cases like:
LOC_RC_SELECTED_TAB = "[id*=_rc-tabs{0}] .tabSelected"
This works just fine:
Why I'm getting this weird behavior ? and how can I solve it ?
Thanks in advance.
Weird behavior, but as specified.
Check the documentation :
Within a String , a pair of single quotes can be used to quote any arbitrary characters except single quotes. For example, pattern string
"'{0}'"
represents string"{0}"
, not a FormatElement . A single quote itself must be represented by doubled single quotes''
throughout a String .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.