title: Set Instance Variable from Method using Java
body: <p>As the title explains I am hoping to be able to <strong>set an Instance Variable using data produced by a calculation contained within a Method</strong>. </p>
  
  <p>I produced an example code to demonstrate what I'm trying to do, as well as a solution I pieced together after scouring the internet. Obviously though, I failed to successfully replicate what others had done. </p>
  
  <p>Thanks in advance for your help.</p>
  
  <p><strong>This code is intended to set the instance variable of "Max" to the value of "6" using the "myMethod" method, and then use the "printMethod" to print the value of "Max".</strong> </p>
  
  <pre><code>public class Main {
  //Main class, Of Coruse. 
      private int Max;
  //The value I wish to be changed by the method. 
  
      public int getMax() {
          return Max; 
      }//The process which is supposed to get the value from the method. 
  
      public static void main(String[] args) {
          Main Max = new Main();
          {
              Max.printMax();
          }
      }//The main method, and non-static reference for printMax. 
  
      public void myMethod() {//Method for assigning the value of "Max" 
          int Lee = 6;
          this.Max = Lee;
      } 
  
      public void printMax() {//Method for setting, and printing the value of "Max" 
          Main max = new Main();
          int variable = max.getMax();
  
          System.out.println(variable);
      } 
  }
  </code></pre>