Java – overrides tostring() using overridden tostring()
•
Java
Basically, that's what I want to achieve
classname @ address(?) [original tostring()], the name of the object and the age of the object
@Override public String toString() { return String.format("%s,%s,%d",this.toString(),this.getName(),this.getAge()); }
Problem, tostring() is called recursively
I can't call super Tostring(), because that's not what I want I want 'this' to call the original tostring()
this
this.super.toString()
It doesn't work for obvious reasons
I have no essence. Can I do this once the method is covered? That is, call the original implementation?
(my editor) basically, what I need is to override toString to display the two properties of the 'this' object. I also want' this' to call the original toString
This is not a project or job Just play (learn) in the Java language thank you
Solution
You are looking for super toString().
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码