I’ve been using MessageFormat.format() for a while, but there’s one thing that I find annoying.
Everytime you declare a parameter in a message, you have to know the position of the mapped argument. e.g.
MessageFormat.format("{0} is annoying {1}.", "this", "indeed")
Is there a class that is the same as MessageFormat in every other way but lets you omit the argument position in parameter declaration altogether and have it default to its position in the message so that the first parameter maps to the first argument, the second parameter to the second argument and so on? e.g.
MessageFormat.format("{} is much better{}.", "this", "indeed")
I think later versions of log4j have a similar feature, but I just need the formatting class.
Happy New Year!
EDIT: I need this feature for assertion, so it’s really for internal use, but I appreciate your insight into why MessageFormat works the way it does.
You should be using
Formatteror its frontend,String.format, instead. You can do: