Is there anything special about toString that makes it unique and more useful to Override compared to just leaving the toString method alone and create a separate method.
For example the following codes. What is the advantage/ disadvantage to Override toString method? Both the methods returns the same output.
@Override
public String toString(){
return String.format("%s is a %s", "Apple", "fruit.");
}
public String newMethod(){
return String.format("%s is a %s", "Apple", "fruit.");
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…