Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

system.out.print vs println

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between the print and println commands?
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.out.println will print on a new line where System.out.print will print and the same line.
 
Ranch Hand
Posts: 805
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic