I am just playing with MessageFormat but when I try to pass a String to MessageFormat format method it compiles fine but then I get a runtime classcast exception. Here is the code.
MessageFormat format = new MessageFormat("");
Object obj = Integer.toHexString(10);
format.format(obj);
Now the runtime exception I get is as follows.
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object; at java.text.MessageFormat.format(Unknown Source) at java.text.Format.format(Unknown Source) at JavaCore2.Codepoint.main(Codepoint.java:21)
is equivalent to format(obj, new StringBuffer(), new FieldPosition(0)).toString();
which in turn(if you jump to another javadoc) is equivalent to format((Object[]) arguments, result, pos). What a nice people work in Oracle! – Incorruption