aspose file tools*
The moose likes Beginning Java and the fly likes system.out.print vs println Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "system.out.print vs println" Watch "system.out.print vs println" New topic
Author

system.out.print vs println

Brandi Love
Ranch Hand

Joined: Sep 19, 2003
Posts: 133
What is the difference between the print and println commands?
S. Stacey
Greenhorn

Joined: Jul 03, 2003
Posts: 20
System.out.println will print on a new line where System.out.print will print and the same line.
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 805
System.out.println will print on a new line where System.out.print will print and the same line.

Println() won't print on a new line, it will terminate the current line with a newline character or sequence. In other words, println() will print an end-of-line character, while print() will not. If you invoke println() after a print(), the argument to println() will append to the argument to print(). Here's an example:

Running this snippet in a program produces Jeff Bosch on one line, then places the cursor at the beginning of the next line.


Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
 
Don't get me started about those stupid light bulbs.
 
subject: system.out.print vs println