0

I have seen that the in the System class (which is imported automatically) there is a static variable of type PrintStreamReader called "out" and it is initialized to "null".

Now in our programs we use System.out.methods_defined(); to call the methods like println() which actually belong to PrintStreamReader class.

  1. How can we access the methods in System.out if the out variable is declared final and intialized to null.

  2. Why is it not possible to directly use an PrintStreamReader object in our code if that is initialized to null to call the methods.

I mean if it's declared in the above way in the System class then why can't we use the same technique in our own code

buneShot
  • 33
  • 5
  • "I mean if it's declared in the above way in the System class then why can't we use the same technique in our own code" You can but you shouldn't. Too easy to get it wrong. – Michael Jun 22 '18 at 09:11
  • @Lino - Yes, but the point of the question is it's a `final` field initialized to `null`, so how can it later have a non-`null` value? (Which the duplicates answer.) – T.J. Crowder Jun 22 '18 at 09:11
  • Thanks for the reply **T.J Crowder** and **Michael**. – buneShot Jun 23 '18 at 13:30

0 Answers0