title: Java How to get call a function of a object from another object variable
body: <p>ok so this is my code:</p>
  
  <pre><code>public class First {
      public static void main(String[] args) {
          Object o;
          Second second = new Second();
          o = second;
          o.doSomething();
      }
  }
  </code></pre>
  
  <p>next page:</p>
  
  <pre><code>public class Second {
      public Second() {
          ...
      }
  
      public static void doSomething() {
          ...
      }
  }
  </code></pre>
  
  <p>then i get NullPointerException
  how can I get "o" to do something?
  any help is appreciated.</p>