print vs println in Java Last Updated : 20 Nov, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report print() and println() are the methods of System.out class in Java which are used to print the output on the console. The major difference between these two is that print() method will print the output on the same line while println() method will print the output on a new line.println() method can be called without arguments. Calling without arguments will prints a blank line and move the cursor to the next line.print() method will only work with arguments else it will give a syntax error.Example: Java // Java program to show the difference between // print() and println() method import java.io.*; class GFG { public static void main(String[] args) { // using print method System.out.print("Hello"); // using println method System.out.println(" Geeks!"); // using print method System.out.print("How are you?"); // using println method System.out.println(" I'm fine."); } } OutputHello Geeks! How are you? I'm fine. print() Methodprint() method in Java is used to display a text on the console. This text is passed as the parameter to this method in the form of String. This method prints the text on the console and the cursor remains at the end of the text at the console. The next printing takes place from just here. void print(boolean b) - Prints a boolean value. void print(char c) - Prints a character. void print(char[] s) - Prints an array of characters. void print(double d) - Prints a double-precision floating-point number.void print(float f) - Prints a floating-point number. void print(int i) - Prints an integer. void print(long l) - Prints a long integer. void print(Object obj) - Prints an object. void print(String s) - Prints a string.Example: Java // Java program to show the // use of print method import java.io.*; class GFG { public static void main(String[] args) { // The cursor will remain // just after the 1 System.out.print("GfG1"); // This will be printed // just after the GfG2 System.out.print("Gf2"); } } OutputGfG1GfG2println() Methodprintln() method in Java is also used to display a text on the console. This text is passed as the parameter to this method in the form of String. This method prints the text on the console and the cursor remains at the start of the next line at the console. The next printing takes place from next line. void println() - Terminates the current line by writing the line separator string.void println(boolean x) - Prints a boolean and then terminate the line. void println(char x) - Prints a character and then terminate the line. void println(char[] x) - Prints an array of characters and then terminate the line. void println(double x) - Prints a double and then terminate the line. void println(float x) - Prints a float and then terminate the line. void println(int x) - Prints an integer and then terminate the line. void println(long x) - Prints a long and then terminate the line. void println(Object x) - Prints an Object and then terminate the line. void println(String x) - Prints a String and then terminate the line.Example: Java // Java program to show the // use of println method import java.io.*; class GFG { public static void main(String[] args) { // The cursor will after GFG1 // will at the start // of the next line System.out.println("GfG1"); // This will be printed at the // start of the next line System.out.println("GfG2"); } } OutputGfG1 GfG2 Comment More infoAdvertise with us Next Article System.out.println in Java A AnshulVaidya Follow Improve Article Tags : Java Java-I/O java-basics Java-Functions Practice Tags : Java Similar Reads System.out.println in Java Java System.out.println() is used to print an argument that is passed to it. Parts of System.out.println()The statement can be broken into 3 parts which can be understood separately: System: It is a final class defined in the java.lang package.out: This is an instance of PrintStream type, which is a 5 min read Formatted Output in Java using printf() Sometimes in programming, it is essential to print the output in a given specified format. Most users are familiar with the printf function in C. Let us discuss how we can Formatting Output with printf() in Java in this article.Formatting Using Java Printf()printf() uses format specifiers for format 5 min read Java.io.PrintWriter class in Java | Set 2 Java.io.PrintWriter class in Java | Set 1 More methods: PrintWriter printf(Locale l, String format, Object... args) : A convenience method to write a formatted string to this writer using the specified format string and arguments. Syntax :public PrintWriter printf(Locale l, String format, Object... 7 min read Java.io.PrintWriter class in Java | Set 1 Java PrintWriter class gives Prints formatted representations of objects to a text-output stream. It implements all of the print methods found in PrintStream. It does not contain methods for writing raw bytes, for which a program should use unencoded byte streams. Unlike the PrintStream class, if au 5 min read PrintWriter println() method in Java with Examples The println() method of PrintWriter Class in Java is used to break the line in the stream. This method do not accepts any parameter or return any value. Syntax: public void println() Parameters: This method do not accepts any parameter. Return : This method do not returns any value. Below methods il 2 min read PrintStream println() method in Java with Examples The println() method of PrintStream Class in Java is used to break the line in the stream. This method do not accepts any parameter or return any value. Syntax: public void println() Parameters: This method do not accepts any parameter. Return : This method do not returns any value. Below methods il 2 min read Like