JAVA : is there a difference between the two references “p” && “pp”?
PrintStream p = new PrintStream(System.out);
p.println("lol");
PrintStream pp = System.out;
pp.println("lol");
I would just like to shorten the System.out.println(); statement for some prototyping.
cheers! matt
No, there’s no behavioral difference between the two.
System.outis already aPrintStream, and anew PrintStream(otherPrintStream)just creates a wrapper object which only delegates to the givenPrintStream.As @MarkoTopolnik suggest, you can even do
and just do
if you want to keep it short.