title: trying to fix java Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
body: <p>We have a gui that we use to set teams, and we assign 2 drivers to each team, plus 2 engines, 1 mechanic and 1 aerodinamic plus 1 strategiest.
  In our gui we set them all and we initialize the value for each of the above. Our GUI is some sort of racing simulation and it is supposed to return the winner.</p>
  
  <p>However everytime we compile the GUI , we get this error:</p>
  
  <blockquote>
    <p>Exception in thread "JavaFX Application Thread"
    java.lang.NullPointerException
          at models.Champ.calcRisk(Champ.java:75)
          at models.Champ.simtRace(Champ.java:102)
          at views.RScene.start(RScene.java:317)
          at views.RScene.lambda$0(RScene.java:107)
          at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
          at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
          at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
          at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
          at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
          at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
          at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
          at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
          at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
          at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
          at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
          at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
          at javafx.event.Event.fireEvent(Event.java:198)
          at javafx.scene.Node.fireEvent(Node.java:8413)
          at javafx.scene.control.Button.fire(Button.java:185)
          at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
          at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
          at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
          at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
          at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
          at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
          at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
          at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
          at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
          at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
          at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
          at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
          at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
          at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
          at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
          at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
          at javafx.event.Event.fireEvent(Event.java:198)
          at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
          at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
          at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
          at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
          at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
          at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
          at java.security.AccessController.doPrivileged(Native Method)
          at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:417)
          at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
          at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
          at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
          at com.sun.glass.ui.View.notifyMouse(View.java:937)
          at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
          at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
          at java.lang.Thread.run(Unknown Source)</p>
  </blockquote>
  
  <p>this is really wierd because we dont know how and why something is zero, we debuged it and it seems everything works fine (by debugging) however when you just run the main method we get all of these following error.</p>
  
  <p>we have a method</p>
  
  <pre><code>public double calcRisk(TDriver td) {
          double risk = MIN_RISK;
          risk += td.getCar().getSetupStrategy();
          risk += (100 - td.getTeam().getStrategist().getProficiency());
          return risk;
      }
  </code></pre>
  
  <p>and also in out method to simulate the race we have:</p>
  
  <pre><code>double crashRisk = calcRisk(td);
  
  and this method:
  private void beginRace() {
  
          int raceNumber = Interact.game.getChamp().getNumber();
          System.out.println("RN " + raceNumber);
  
          StartInterac.game.getCham().simulateNextRace();
  
          rScene();
  
      }
  </code></pre>
  
  <p>and the next error is in the following method:</p>
  
  <pre><code>private void raceStartScene() {
          .....rest of the code.......
          raceBtn.setOnAction(e -&gt; {
              beginRace();
          });
  
          ......rest of the code......
      }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>we have amethod geeTeam which is located in a class called DriverPerTeam</p>
  
  <p>we put a check for this method:</p>
  
  <pre><code>public double calcRisk(TDriver td) {
  System.out.println("---check----");
              System.out.println("1 "+td.getTeam());
              System.out.println("2 "+td.getTeam().getStrategist());
              System.out.println("3 "+td.getTeam().getStrategist().getProficiency());
          System.out.println("-------------");
          double risk = MIN_RISK;
          risk += td.getCar().getSetupStrategy();
          risk += (100 - td.getTeam().getStrategist().getProficiency());
          return risk;
      }
  </code></pre>
  
  <p>and now it returns answer like this:</p>
  
  <blockquote>
  <pre><code>    ---check----
      1 models.Team@627f66d0
      2 models.Strategist@1c00c341
      3 71.0
      -------------
      ---check----
      1 models.Team@627f66d0
      2 models.Strategist@1c00c341
      3 71.0
      -------------
      ---check----
      1 null
      Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
        at models.Champ.calcRisk(Champ.java:76)
        at models.Champ.simRace(Champ.java:108)
        at views.RScene.beginRace(RScene.java:317)
  .
  .
  .
  .
  ---check----
  1 models.Team@627f66d0
  2 models.Strategist@1c00c341
  Exception in thread "JavaFX Application Thread" 3 71.0
  -------------
  ---check----
  1 models.Team@627f66d0
  2 models.Strategist@1c00c341
  3 71.0
  -------------
  ---check----
  1 null
  java.lang.NullPointerException
    at models.Champ.calcRisk(Champ.java:76)
    at models.Champ.simRace(Champ.java:108)
    at views.RScene.beginRace(RScene.java:317)
  .
  .
  .
  .
  .
  .
  </code></pre>
  </blockquote>
  
  <p>anyone can help me in this situation??</p>