title: How to use getters and setters in two different classes
body: <p>how to use getter setter in two different class</p>
  
  <pre><code>Class A{
  
      int a = 10;
      GetterAndSetter gs = new GetterAndSetter();
      gs.setValue(a);
  }
  
  
  Class GetterAndSetter {
      int a ;
      public void setValue(int a){
      this.a = a;
  }
  
  public int getValue(){
  
  return a;
  
     }
  
  }
  
  
  class B {
  
      int c;
      GetterAndSetter gs = new GetterAndSetter();
      c = gs.getValue();
  }
  </code></pre>
  
  <p>While printing c it gives null. And tell me if it is valid or not.</p>