Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IDEA: How to create toString() using superclass

If A extends B, using IntelliJ idea, how can i generate toString() using B's public (or protected) methods automatically.

In this example, how can i include public methods from the FileRow?

enter image description here

like image 635
James Raitsev Avatar asked Oct 16 '12 00:10

James Raitsev


People also ask

How do you call toString method from superclass in subclass?

In a subclass, toString() can call the superclass toString() method using super. toString() and then add on its own attributes. In the following code, the Person class overrides the Object toString() method and the Student class overrides the Person toString() method. They each add on their attributes.

What does Super toString () do?

super keyword is used to call parent class methods in case of inheritance. Every class is the child of Object class in java and one of its non-final methods is toString() . So super. toString() calls Object class method toString() .

What is toString in java?

The toString method is used to return a string representation of an object. If any object is printed, the toString() method is internally invoked by the java compiler. Else, the user implemented or overridden toString() method is called.


1 Answers

There is a template to use super.toString(), but there is no way to reference superclass members directly. It may be worth submitting a new request for this feature.

like image 109
CrazyCoder Avatar answered Oct 04 '22 06:10

CrazyCoder