Java inheritace

I am learning Java . I got stuck in basic Inheritance property.

Can any one explain will be of great help.

    public class A{
      int x;
      protected void setX(){
        int x = 2;
      }
      protected int getX(){
        return x;
      }
    }

    public class B extends A{
      
     System.out.println(getX); // ERRoR.
    }

Error give me Null Pointer.

[chk this link][1] . i used this this link to understands inheritance.




   


  [1]: http://xahlee.org/java-a-day/extend.html
Java inheritace
===


I am learning Java . I got stuck in basic Inheritance property.

Can any one explain will be of great help.

    public class A{
      int x;
      protected void setX(){
        int x = 2;
      }
      protected int getX(){
        return x;
      }
    }

    public class B extends A{
      
     System.out.println(getX); // ERRoR.
    }

Error give me Null Pointer.

[chk this link][1] . i used this this link to understands inheritance.




   


  [1]: http://xahlee.org/java-a-day/extend.html