title: Updating variables in the main method?
body: <p>I am making a car game in java. The speed of the road is set in the main method, but I need to update the speed (the car going out of bounds and being slowed by grass).</p>
  
  <p>Here is the part were the int that I want to control the speed is changed at. </p>
  
  <pre><code> if(collision[12] &gt; x)        
   {
      roadSpeed = 150;
      System.out.println("outside");
   }
   else
   {
      System.out.println("inside");
      roadSpeed = 100;
   } 
  </code></pre>
  
  <p>Here is the main method up to the point that I need to update.</p>
  
  <pre><code>public static void main(String[] args) 
  {
      EventQueue.invokeLater(new Runnable() {
          public void run() {
              final TestRoad road = new TestRoad();
              road.timer.setDelay(roadSpeed);
  </code></pre>
  
  <p>After the int is changed the main method does not update the timer delay.
  I have looked at changelisteners but I don't want any buttons or sliders.</p>
  
  <p>were the int is declared in were it is called</p>
  
  <pre><code>public Boolean start = true;
      public int i;
      public int x;
      public int y;
      public int z;
      public static int roadSpeed = 100; //&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;declared here      
      public int lcolPoint = 0;
      public int rcolPoint = 0;
      public int colSlot = 0;
      public int colOffset = 0;
      public int carY;
      public int[] collision;
      public int[] colBuffer;
      private BufferedImage carImg;
      private Boolean right=false;
      private Boolean left=false;
      private Boolean first=true;
  
  
  
  
      public TestRoad(){
  
          this.setFocusable(true);  
          addKeyListener(this);                        //THIS IS ADDING THE KEYLISTENER
          Color colors = new Color(51,102,0);            
          setBackground(colors);
  
  
          //uses setPreferredSize instead of setSize because parent component utilizes a layout manager.
          setPreferredSize(new Dimension(500, 500));
  
          collision = new int[500];
          colBuffer = new int[2];
  
          for(int i=0; i&lt;500; i++){
                  collision[i] = 0;   
          }   
  
  
          timer = new javax.swing.Timer(25, new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                  addPoint();
                  carMove();    //&lt;&lt;&lt;&lt;&lt; called here
                  repaint();
              }
          });
  </code></pre>
  
  <p>carmove -</p>
  
  <pre><code>public void carMove()
      {
          if(right==true)
              x+=8;
  
          if(left==true)
              x-=8;
  
              colBuffer[0] = collision[1];
              collision[1] = lcolPoint;
  
               collision[colSlot] = lcolPoint;
  
             for(int z=2; z&lt;21; z++){
              colBuffer[1] = collision[z];
              collision[z] = colBuffer[0];
              colBuffer[0] = colBuffer[1];
             }    
  
              if(collision[12] &gt; x)        
              {
                  roadSpeed = 100;
                  System.out.println("outside");
              }
              else
              {
                  System.out.println("inside");
                  roadSpeed = 50;
              }   
  
  
      }
  </code></pre>