Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Diffrence between System.out.println and System.err.println.  RSS feed

 
Prakash Rai
Ranch Hand
Posts: 107
Eclipse IDE MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q1. What is difference between

AND



Q1) If output of both code are same then what is the differences

Q2. And please tell the correct usages of both.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One writes to standard output and one writes to standard error. Although these normally write to the same place, they are two separate streams and so can be redirected individually, so you could (for example) redirect standard output to a file but leave standard error writing to the command line.
Note also that because they are two separate streams, if you haven't redirected either of them, you cannot guarantee the order in which any messages are written. Try experimenting with a program that mixes lots of each call together and see what output you get.
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Also standard input, standard output, and standard error are more related to the operation system, than Java specific. It may be better to research more on what the OS does with it first.

Henry
 
Prakash Rai
Ranch Hand
Posts: 107
Eclipse IDE MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!