title: How to change the value of a variable in one class from another? Java
body: <p>I am having issues getting variables I have declared in one class to update from another class. Is this even possible in Java? </p>
  
  <p>Here is the portion of the class that I want the values to change in.</p>
  
  <pre><code>public class DrawMaze {
     // Width of border in pixels
     public static int borderwidth = 40;
  
     // Size of maze cell in pixels
     public static int cellsize = 30;
  
     // Time to sleep after a move (in milliseconds)
     // Change to default to 50. 1000 gives time to observe the program.
     public static int sleep time = 1000;
  }
  </code></pre>
  
  <p>And here is a portion of my second class where the values of <code>cellsize</code>, <code>borderwidth</code>, and <code>sleeptime</code> are to be changed using command line arguments.</p>
  
  <pre><code>public class MazeSolver {
      // Get the cell size, border width, and/or the sleep time if available 
     try{
         if (args.length &gt;= 2){
             DrawMaze.cellsize = Integer.parseInt(args[1]);
             if (!(DrawMaze.cellsize &gt;= 10)){
                System.out.println("Cellsize must be an integer greater than or equal to 10."); 
             }
         }
         if (args.length &gt;= 3){
             DrawMaze.borderwidth = Integer.parseInt(args[2]);
             if (!(DrawMaze.borderwidth &gt;= 5)){
                    System.out.println("Borderwidth must be an integer greater than or equal to 5."); 
             }
         }
         if (args.length == 4){
             DrawMaze.sleeptime = Integer.parseInt(args[3]);
             if (!(DrawMaze.sleeptime &gt;= 0) &amp;&amp; !(DrawMaze.sleeptime &lt;= 10000)){
                    System.out.println("sleeptime must be an integer in the range of 0 to 10,000."); 
             }
         }
  }
  </code></pre>