6 Replies Latest reply on Oct 5, 2008 11:21 PM by 807589

    Help with Exception in thread "main" java.lang.NullPointerException

    807589
      I got this exception while running the code in Netbeans IDE 6.1. The code is compiling fine...Please tell me what the problem is


      Exception in thread "main" java.lang.NullPointerException

      at Softwareguide.chooseanswer(Softwareguide.java:32)

      at Driver.main(Driver.java:7)
      public class Driver
      {
          public static void main(String[] args)
          {
              Softwareguide swguide = new Softwareguide();
      
              swguide.chooseanswer();
          }
      }
      public class Softwareguide
      {
          State test1;
          State test2;
          State test3;
          State test4;
          State test5;
          State subtest1;
          State subtest2;
          State subtest3;
          State subtest4;
          State subtest5;
      
          State state = test1;
      
          public Softwareguide()
          {
              test1 = new Test1(this);
              test2 = new Test2(this);
              test3 = new Test3(this);
              test4 = new Test4(this);
              test5 = new Test5(this);
              subtest1 = new SubTest1(this);
              subtest2 = new SubTest2(this);
              subtest3 = new SubTest3(this);
              subtest4 = new SubTest4(this);
              subtest5 = new SubTest5(this);
          }
      
          public void chooseanswer()
          {
              state.chooseanswer();
          }
         /* public void chooseyes()
          {
              state.chooseyes();
          }
      
          public void chooseno()
          {
              state.chooseno();
          }*/
      
          public State getState() 
          {
              return state;
          }
      
          void setState(State state)
          {
           this.state = state;
          }
      
          public State getTest1State()
          {
              return test1;
          }
      
          public State getTest2State()
          {
              return test2;
          }
      
          public State getTest3State()
          {
              return test3;
          }
      
          public State getTest4State()
          {
              return test4;
          }
      
          public State getTest5State()
          {
              return test5;
          }
      
          public State getsubTest1State()
          {
              return subtest1;
          }
      
          public State getsubTest2State()
          {
              return subtest2;
          }
      
          public State getsubTest3State()
          {
              return subtest3;
          }
      
          public State getsubTest4State()
          {
              return subtest4;
          }
      
          public State getsubTest5State()
          {
              return subtest5;
          }
      
          public String toString()
          {
              StringBuffer result = new StringBuffer();
              result.append("\n Starting Diagnostic Test...");
              return result.toString();
          }
      }