Isn't it  System.out.println rather than System.out.printf , i'm new so i dont get it.,(reply>)," <a href=""https://docs.oracle.com/javase/7/docs/api/java/io/PrintStream.html"">https://docs.oracle.com/javase/7/docs/api/java/io/PrintStream.html</a>",(reply>), Printf stands synonymously for "print format", like "Print and format the string with the parameters, I provided to you". Println stands for "print line",(reply>), printf is a varargs function, so it needs an Integer object as an input, which it gets by boxing the primitive int 4 (result of 2+2). Since it is a small, often used value, the compiler directly uses the cached object to save time. Except we've just replaced the object for 4 with the object for 5, so printf will use print 5 instead. Doing it with println would just use primitive type logic and the correct arithmetic result would appear.