java - Accessing inner class methods on already created outer class object -
let's have class this:
class outer { public void getoutervalue() { } class inner { public void getinnervalue() { } } }
i understand create object of class as:
outer outer = new outer(); outer.inner inner = outer.new inner();
but let's suppose getting object other method:
void somemethodsomewhere(outer o) { // how call getinnervalue() here using o? }
is there way call "getinnervalue" method using "o" in scenario above?
please let me know.
no. need have instance of inner
call methods on it.
an instance of outer class not enough (it work other way around: inner class instance has reference outer class instance).
Comments
Post a Comment