Difference Between System.out.print() and System.out.println() Function in Java
In Java, we have the following functions to print anything in the console.
- System.out.print() and
But there is a slight difference between both of them, i.e.
System.out.println() prints the content and switch to the next line after execution of the statement whereas
System.out.print() only prints the content without switching to the next line after executing this statement.
The following examples will help you in understanding the difference between them more prominently.
Welcome to JAVA (1st line) Welcome to GeeksforGeeks (2nd line) Hello Geeks (2nd line)
Welcome to JAVA (1st line) Welcome to GeeksforGeeks (1st line) Hello Geeks (2nd line)
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.