Search code examples
javasubclasstostringsuperclass

toString method with subclasses


I am creating a program with many subclasses (A through G) and am trying to use the toString method to create a printable representation of an object reference from the subclass G. Class G inherits from class F. I'm not too familiar with toString yet and can't figure out how to do something like this. Thanks for any help!


Solution

  • @Override
    public String toString() {
        return /* fill this in */;
    }