0

Possible Duplicate:
java: “final” System.out?

Can someone please help me in understanding how the setOut method works?
It can change the current pipe lining of System.out from Monitor to PrintStream object, but how is it changing reference of out?

Community
  • 1
  • 1

2 Answers2

2

System#setOut internally calls a native method to redirect out. In other words: voodoo magic ;)

Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268
0

Since Java is open source, let's have a look:

http://www.mavenjava.com/sun/jdk/1.6.0/src/java/lang/System.java.html#System.setOut%28java.io.PrintStream%29

It calls out to a native method to set the output - the JVM basically bypasses the "final" check.

Paolo
  • 22,188
  • 6
  • 42
  • 49