Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between System.out and Printstream

Tags:

java

Is there any difference in these statements

System.out.println(error);

AND

PrintStream ps = new PrintStream((OutputStream)System.out);
ps.println(error);
like image 632
Anand B Avatar asked Feb 06 '13 10:02

Anand B


People also ask

Is system out a PrintStream?

out object." System. out is a static PrintStream variable called out in the System class. This variable has the final modifier, so you simply assign it a new value.

What is the difference between system in and system out?

System.in is the input stream connected to the console, much as System. out is the output stream connected to the console. In Unix or C terms, System.in is stdin and can be redirected from a shell in the same fashion. System.in is the static in field of the java.

What is a system out?

System: It is a final class defined in the java. lang package. out: This is an instance of PrintStream type, which is a public and static member field of the System class.


1 Answers

System.out is already a PrintStream,

PrintStream ps = new PrintStream((OutputStream)(System.out));

would only wrap it once more which seems pointless.

like image 139
stacker Avatar answered Sep 22 '22 19:09

stacker