Home  >  Forum  >  Core Java
Post New Query

Difference between println() method of PrintWriter and System.out


joined on
February 03,2015
Asked on March 04,2015
Hi Seniors,

I am a student and learning Servlet. I need to understand what is difference between println() method of PrintWriter and System.out.

Thanks
joined on
February 22,2015
Replied on March 04,2015

1-System is a class which include for input.output and error.

2-Out is static variable which is used for output.

3-And println() is to write output on console.
joined on
March 15,2013
Replied on March 04,2015

System.out.println(): while using println() with System.out, it will print on the console.

PrintWriter.println(): PrintWriter can write to other sources than just the console, it can write to an HttpResponse.
joined on
November 18,2013
Replied on March 04,2015

With System.out.println(..) we can print to Console.

But System.out internally creates PrintWriter object.So why cant we use 
PrintWriter.println(..) directly to write to console.

Write Answer



Sitewide-Feb4of4234x60





Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us