-2

So... I have a parent class which overrides default toString() method and another class which inherits (extends) the first class. Is there a way to override toString() method of the second class so it just to append text next to the output of toString() method of its parental class?
This is the code of the parental class:
@Override public String toString(){ return String.format("First Name: %s%nLast Name: %s", getFirstName(), getLastName()); }
I would like just to append Facility number: %s at the end of the string.

1 Answers1

1

You can get use super before toString() method. It let you use method from base class. The word this give you method from class which is extended by base class.

sszledak
  • 11
  • 2