In System.out.println,’out’ is a member variable of System class and it’s also an instance of PrintStream class.So can anyone please tell me whether out can be a member of System class which is an object of PrintStream class or not?And please highlight me about System.out.println.
In System.out.println ,’out’ is a member variable of System class and it’s also an
Share
It’s just a public static final variable. Any time you write:
you’re fetching the value of that variable (which is a
PrintStreamreference) and callingprintln()on it. If it helps, think of it as:System.outis not an instance ofPrintStreamitself – it’s a variable. The value of the variable isn’t aPrintStreamobject, either – it’s a reference to an object which is either aPrintStreamor a subclass instance.