Wednesday, January 21, 2009

Difference between Sysyem.out.println and System.out.print in Java

Welcome back to Java Code Online. System.out.print and System.out.println are used to print the output at the console. It is one of the most commonly used command in Java.

Often while coding we come across System.out.print and System.out.println. Have you ever wondered what could be the possible difference between these two Java Commands. I will explain it to you:-
1. System.out.print prints the output in the same line.
2. System.out.println inserts a new line there by enhancing the beauty of the output.

println of System.out.println is normally interpreted as print new line. So you can remember it easily. If you want that your Java code output appears in a new line each time, then use System.out.println. But if you want that all the Java Code output should continue coming on the same line, then use System.out.print.

I hope the article clarifies your doubt about System.out.print and System.out.println. If you liked the article then do leave a comment. For more info on Java, keep buzzing Java Code Online.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.