+ 5
What is the deference System.out.print (); & System.out.printf();
4 Respuestas
+ 12
Unlike System.out.println() or System.out.print() which is type void (prints something and does not return anything), System.out.printf() is PrintStream type: prints something and returns PrintStream.
System.out.println() and System.out.printf():
- System - is the final class from the java.lang package
- out - is a class variable type PrintStream declared in System class
- println - is the method of the PrintStream class
- printf - is the method of the PrintStream class
This explanation By LukarToDo.
+ 8
Using print() instead of println() does not break the line.
• Java String Format Examples:- https://dzone.com/articles/java-string-format-examples
⇨ Check thisOut:- https://alvinalexander.com/programming/printf-format-cheat-sheet
//Thanks to Haris 😉🍻
+ 5
Mike is right. It is not fair to downvote someone if he give not a wrong answer. Maybe the answer is a bit imprecise, but there you can ask what exactly is meant.
System.out.print () --> print it and leave the cursor in the same line
System.out.println () --> print it but the cursor is now on the next line
System.out.printf () format your output --> https://www.baeldung.com/java-printstream-printf
+ 1
In most programming languages, printf is generally a more formatted output.