title: NullPointerException when accessing static variable in another class in Java
body: <p>I have trying to access a static variable of class A in class B, however I am getting NullPointerException. The code is :</p>
  
  <pre><code>public class OutgoingMessage {
      public static SMPPSession session;
      public static void main(String [] args)
      {
           session = new SMPPSession();
  
      }
    }
  </code></pre>
  
  <p>And </p>
  
  <pre><code>public class SendSMS {
      public static void main(String [] args)
      {
        if(OutgoingMessage.session.getSessionState().toString().equals("Connected"))//Line 44 
          {
          }
      } 
  }
  </code></pre>
  
  <p>The error reads </p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
          at SendSMS.main(SendSMS.java:44)
  </code></pre>
  
  <p>Any idea what am I missing ?</p>
  
  <p>Thanks</p>
  
  <p>Satya</p>