That's a reault of the JavaScript type system. All numbers in JavaScript are doubles, so while `Integer.parseInt("4.5") returns 4, it needs to be converted to 4.0 for JavaScript.
Fortunately, 64-bit doubles have enough precision to represent any 32-bit int exactly, so on the JavaScript side you typically don't need to worry about it. But the Java object behind the value is always a Double
and gets converted automatically when it needs to be. But since System.out.printf
takes arguments of type Object
it has to be passed as is.