Difference between ?System.out.println?
and ?System.error.println??

Answer Posted / k.v.subrahmnyareddy

We can redirect System.out to another file but we cannot
redirect System.err stream.

ex:
public class TestSystOutAndErr
{
public static void main(String[] args)
{
System.out.println("system.out.message");
System.err.println("system.err.message");
}
}
compile:
>javac TestSystOutAndErr.java

execute:(first time)

>java TestSystOutAndErr

OutPut:
system.out.message
system.err.message

execute:(second time)

>java TestSystOutAndErr > samp.txt

output:
system.err.message
(In the above execution "system.out.message" redirected in
to samp.txt file but "system.err.message" not redirected
into samp.txt file)

request:

hi,
I'm M.C.A studet if there is an wrong plz excuse me.
tnaq

Is This Answer Correct ?    7 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Add a value x to array from index l to r where 0 <= l <= r <= n-1

633


When a byte datatype is used?

568


What is object class in java?

505


When can an object reference be cast to an interface reference in java programming?

584


What is an empty list in java?

531






Name component subclasses that support painting in java programming?

639


extending thread class or implementing runnable interface. Which is better? : Java thread

566


What one should take care of, while serializing the object?

484


Which number is denoted by leading 0x or 0x in java?

564


How are variables stored?

533


Why hashcode is used in java?

500


Can we extend a class with private constructor?

527


If two threads have same priority which thread will be executed first ?

844


What are static methods?

578


What is a stringbuffer?

514