java - Inheritance with this and super -
working in java.
i have abstract class such:
public abstract class foo { protected logger log = null; // other stuff public boolean isloggerset() { return (this.log != null) ? true : false; } } now extend class such:
public class bar extends foo { public bar() { this.log = logger.getlogger(bar.class); } public void somemethod(string[] args) { bar b = new bar(); if(b.isloggerset()) { // stuff } } } the question: bar.class referring super.log though call this.log since bar not have it's own local variable called log? or correct way implement isloggerset() method make abstract , force bar.class implement on it's local copy of log since it's been extended?
basically have this.log in foo class because, refers itself. in bar class want able null check log, should instead using super.log = in bar.class?
you have not set logger static, instead protected. whether use super or this, point exact same variable in case.
Comments
Post a Comment