title: How to call a returned value to java function here
body: <p>This is the code I have written to check for armstrong nos, but am unable to access the value returned in the check() function.</p>
  
  <p>Error  : Cannot find Symbol - variable sum</p>
  
  <p>How am I to fix this..</p>
  
  <p>Also tell if this is the way I should use the main method to access execute the program and jump from one function to another or is there another method which will be better.</p>
  
  <pre><code>    import java.util.Scanner;
      class Arm_check
      {
          int n=0;
          public void main()
          {
              getnum();
          }
  
          void getnum()
          {
              System.out.println("Enter a No.");
              Scanner Prakhar=new Scanner(System.in);
              n=Prakhar.nextInt();
              check();
              int ori=n;
          }
  
          int check()
          {
              int digits=(int)Math.floor(Math.log10(n)+1);
              System.out.println("No of Digits :"+digits);
              int a[]=new int[digits];
              int sum=0;
              for(int i=0;i&lt;digits;i++)
              {
                  a[i]=n%10;
                  n=n/10;
              }
              for(int i=0;i&lt;a.length;i++)
              {
                  sum=(int)Math.pow(a[i],3)+sum;
              }
              System.out.println(sum);
              return sum;
              dispsum();
          }
  
          void dispsum()
          {
              int z=check(sum);
  
              if(z==ori)
              {
                  System.out.println("No. is Armstrong");
              }
              else
                  System.out.println("No. is not Armstrong");
          }
      }
  </code></pre>
  
  <p>Thanks..</p>