9 Replies Latest reply on Mar 16, 2009 12:32 PM by 807588

    Using the word super to access superclass fields - How?

      I just read that it is possible to access public members of the superclass by using the keyword super. To test it, I tried the following but it does not work. What is the proper way?
      public class A {
           public String color = "Black";     
      public class B extends A{
           public String color = "White";
      public class test {
           public static void main(String[] args) {
                A x= new A();
                B y= new B();
                System.out.println(x.color); //returns Black
                System.out.println(y.color); //returns White
                System.out.println(y.super.color); ERROR!!!