[Logo]
Forums Register Login
why String vlass reference variable holds content ?


why s displays JAVA is displyed ?




but here x is not displaying JAVA
what to do for displaying JAVA here should i need to change the state of this object?
by overriding toString method why it displays string value when reference is displayed?

Look up PrintWriter.println(Object) in the API to see why.

This method is being called, because System.out is a PrintWriter.
Hello,

Println() method converts all its parameters to String to print it on console. If it finds the object, then it will call the toString() method on that object.


One good example of runtime polymorphism

is out a PrintWriter object or a PrintStream object ?
 
is out a PrintWriter object or a PrintStream object ?

That's easy enough to find out in the javadocs, isn't it?
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Nov 24, 2017 21:30:24.