Quantcast
Channel: Java this in parent and child not working as expected - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by midor for Java this in parent and child not working as expected

$
0
0

The way you would set the s-member in the parent-portion of a child-class, would be to offer a protected constructor (it could, of course, also be public):

protected Parent(String s) { this.s = s; }

which sets the string to the given value. You would then call this constructor as the first call in your child-constructor with

super("Whatever you want");


Viewing all articles
Browse latest Browse all 4

Trending Articles



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