why we turned to access superclass members although we can inherit them?

Dzuma

New Member
if we have 2 class Zoo & Moo as follows:\[code\]public class zoo { String superString="super"; private String coolMethod(){ return "Zoo method"; }}public class Moo extends zoo{ public void useMyCoolMethod(){ zoo z=new zoo(); System.out.println(superString);//1 System.out.println(z.superString);//2 } public static void main(String[]args){ new Moo().useMyCoolMethod(); }}\[/code\]at 1 & 2 we print the value of the String in the super class through inheritance and access, the question is , what is the benefit of Access although i can do the same thing by inheritance ? knowing that the Access approach isn't allowed if the two classes is in diff packages
 
Top