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




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



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.



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.



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











©2024 concretepage.com | Privacy Policy | Contact Us