Quantcast
Channel: JetBrains Developer Community : Thread List - IntelliJ IDEA Users
Viewing all articles
Browse latest Browse all 5661

Generate toString with parent member variables?

$
0
0

Maybe I am missing something obvious, but I can't seem to make toString generation include parent member variables.

 

For instance for with the following to classes Foo and Bar, the Intellij IDE generates Bar.toString() which includes b but not a.  How do I fix this?

 

public class Foo {
    private String a;

    public String getA() {
        return a;
    }

    public void setA(String a) {
        this.a = a;
    }
}

public class Barextends Foo {
    private String b;

    public String getB() {
        return b;
    }

    public void setB(String b) {
        this.b = b;
    }

    @Override
    public String toString() {
        return "Bar{" +
                "b='" + b + '\'' +
                '}';
    }
}

Viewing all articles
Browse latest Browse all 5661

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>