title: Accessing methods and attributes from another class without instantiating it
body: <p>Say I have the following code:</p>
  
  <pre><code>class A {
      public static void main(String[] args) {
          B b = new B();
          System.out.println(b.getB() + " and count " + b.count);
      }
  }
  
  class B {
      private int b = 15;
      int count = 0;
  
      B() {
          count++;
      }
  
      public int getB() {
          return b;
      }
  }
  </code></pre>
  
  <p>The output is</p>
  
  <pre><code>15 and count 1
  </code></pre>
  
  <p>Which, depending on the use, is ok.</p>
  
  <p>However, <code>count</code> is the total amount of objects of type B, and it is added 1 every time a <code>new B();</code> comes up. In the code, the third line (where there is a <code>new B();</code>), is not supposed to do that. I simply want a reference to the class B, in order to access its attributes and methods.</p>
  
  <p>Is there a way to access methods and attributes without instantiating it?</p>