Just came to know that java
does has a method named printf
, then what is the difference between printf
& println
?
difference between printf and println in java? [duplicate]
System.out.println();
is efficient for simply printing a line of text. If the line of text needs to be formatted (ex: alignment (left-justified, etc.), etc.), then System.out.printf();
would be used.
Check out this link for more information.
© 2022 - 2024 — McMap. All rights reserved.
printf
is like the Cprintf
function, "print format", the other is a more (or less) updated version, which doesn't require a format and value list...What does the JavaDoc's tell you? – Picriteformat
andprintf
the same ? – Troikaprintf
is confusing and be difficult to use if you've not used it before. You can useprintln("Say " + word)
orprintf("Say %s%n", word)
, which one is generally more easier to read? C doesn't have aString
in the sense that Java does, so allowingprintln
simplifies the process – PicriteString.format
. – Hiramhirasuna