title: Using setters and getters between 3 classes
body: <p>I know this is a basic question but I really struggle with this :(</p>
  
  <p>First class:</p>
  
  <pre><code>public class A{
  
  
  C c= new C();
  B b= new B();
  
  public static void main(String[] args) {
      b.start();
      System.out.println(c.getSomething());
      }
  }
  </code></pre>
  
  <p>Second Class:</p>
  
  <pre><code>public class B{
  
  
  C c= new C();
  
  public void start(){
     c.setSomething(2);
      }
  }
  </code></pre>
  
  <p>Third Class:</p>
  
  <pre><code>  public class C{
  
  
  int x;
  
  
    public int getSomething() {
      return x;
  }
  public void setSomething(int x) {
      this.x = x;
  }
  }
  </code></pre>
  
  <p>Now I know I make a new object in class A thats why the sysout returns null.
  How can I make it so that I GET the value 2 instead of null in class A, and that I'm able to SET things in class B.
  So I stay at the same object so to say.</p>
  
  <p>I just want to be able to SET things in class B and GET that same value from the setter-getter-class-C, in class A. Please help</p>
  
  <p>Thanks in advance, Jimme</p>