This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Printwriter vs System.out.println() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Printwriter vs System.out.println()" Watch "Printwriter vs System.out.println()" New topic

Printwriter vs System.out.println()

Muhammad usman shad
Ranch Hand

Joined: Jan 06, 2010
Posts: 30
why we dont use Printwriter class for output in java instead of system.out.println???
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2904

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.

[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
John de Michele

Joined: Mar 09, 2009
Posts: 600

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.

Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2904

Thats more correct answer, John.
I agree. Here's the link:
subject: Printwriter vs System.out.println()
It's not a secret anymore!