java - How to: Access a getter from main? -


i don't understand why getter class isn't working.

the getter set follows in class called site. (there class called pagenode defines elsewhere)

    private pagenode homepage;  public void sethomepage(pagenode homepage){     this.homepage = homepage; }  public pagenode gethomepage(){     return homepage; } 

now, understanding reference homepage in main, need call follows:

pagenode refhomepage = gethomepage(); 

but doesn't work, , neither gethomepage itself.

edit expansion: home page should set reference site

sortedadt website = new site().

but trying website.gethomepage doesn't work - gethomepage doesn't show up.

it might because i've been working on day , i'm still learning java, don't understand why isn't working.

if getter resides in class site, wrote, should call on instance of class (as john no suggested). code in main this:

site mymainsite = new site(); //...  pagenode refhomepage = mymainsite.gethomepage(); //... 

edit: ok, after edit: have parent class sortedadt - 1 have gethomepage method? if not, won't work either, if reference of type sortedadt.


Comments