Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Printwriter vs System.out.println()  RSS feed

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why we dont use Printwriter class for output in java instead of system.out.println???
 
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

JavaDocs wrote:
All characters printed by a PrintStream are converted into bytes using the platform's default character encoding. The PrintWriter class should be used in situations that require writing characters rather than bytes.

 
Rancher
Posts: 600
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Muhammad:

It is also because the PrintWriter class didn't come until JDK 1.1, while the System and PrintStream classes have been in the API since 1.0. Since the in/out/err objects are publicly exposed, they couldn't be changed without breaking backwards compatibility.

John.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats more correct answer, John.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!