title: Access a method's variable in Java
body: <p>I am new to Java so I need help.</p>
  
  <p>How can I access the variables of the method <code>method1</code> and compare them with the variable <code>int c</code>? What should I return?</p>
  
  <pre><code>public static void main (String [] args){
  
      int c = 30;
  
   // I want to compare c with a, for example:
  
      if (c &gt; a)
      {
           System.out.println(c + " is greater than " + a);
      }
  
  }
  </code></pre>
  
  <p>I want to do the above comparison without touching <code>method1()</code></p>
  
  <pre><code>public double method1(){
  
      int a = 10; int b = 20;
  
      if (a &gt; b)
      { 
          System.out.println(a + " is greater than " + b); 
      } 
      else if (a &lt; b)
      { 
          System.out.println(b + " is greater than " + a); 
      }
  
     //What should I return?
  
      return ????; 
  
  }
  </code></pre>