I thought it will expect a String parameter and gives Runtime Exception.
Have you looked at format() methods signature, it takes var arg type of Object., So 1 is autoboxed in Integer type. No Exception !
Banu Chowdary wrote:
But for gives error.
It doesn't give error, because it syntactically correct, but throws RuntimeException , stating "IllegalFormatConversionException: d != java.lang.String" , it means, you passed string and format specifier expect a Integer object or int.