title: What is the reason why this variabe change from main method is not effected on upper Class
body: <p>Please forgive if it is too much of a novice question, but I need your help to understand why the call to b.createNumB(1) in the main method would effect the change on numB in ClassB.</p>
  
  <pre><code>class ClassB {
          int numB = 0;
          public int getNumB(){
              return numB;
          }
          void createNumB(int num){
              numB = num;
          }   
      }
  
      public class ClassA {
          ClassB b = new ClassB();
  
          // Returns numB from ClassA
              public int returnB(){
              return b.getNumB();
          }
  
           public static void main(String[]args){   
               ClassA a = new ClassA();
               ClassB b = new ClassB();
  
         //My espectation is that b.createNumB(1) should update numB in ClassA
               b.createNumB(1);
               System.out.println(a.returnB());
           }   
          }
  </code></pre>
  
  <p>The code when run prints 0 instead of 1; Please I need an explanation to what is
  happening behind this code. thanks.</p>