Is there any difference in these statements
System.out.println(error);
AND
PrintStream ps = new PrintStream((OutputStream)System.out);
ps.println(error);
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.
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.
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.
System.out
is already a PrintStream
,
PrintStream ps = new PrintStream((OutputStream)(System.out));
would only wrap it once more which seems pointless.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With