title: How to use a variable of one method in another method?
body: <p>I want to know how can I use the variable <code>a[i][j]</code> in the method <code>Scores()</code> to use it in the methods <code>MD()</code> and <code>sumD()</code> in the following code:</p>
  
  <p>In my code, the methods <code>MD()</code> and <code>sumD()</code> can't get the result.</p>
  
  <pre><code>public class Test3 {
  
    public void Scores() { 
     double[][] a= new double[3][5];
     int i,j;
  
     for(i=0; i&lt;3; i++ ){
          for(j=0; j&lt;5; j++){
                  a[i][j]= (double) Math.random(); 
                  System.out.println("a[" + i + "][" + j + "] = " +a[i][j]);
          }   
     }   
  }
    public void MD(){
     double[][] b =new double[3][5];
     int [] m = new int[5];
     int i,j;
     //double[][] a= new double[3][5];
  
     for(j= 0; j&lt;5; j++)
          for(i=0 ; i&lt;3 ; i++) 
          {
             b[i][j]=0.0;                                                    
             if(a[i][j]&gt;0.0) 
                m[j]++;
          }   
      for(j= 0; j&lt;5; j++){
          for(i=0 ; i&lt;3 ; i++) {
             if(a[i][j] &gt; 0.0){
                 b[i][j]=a[i][j]*m[j];
                 System.out.println("b[" + i + "][" + j + "] = " + b[i][j]);
             }    
         }        
     }                
  }
  
  public void sumD(){
  
  int i,j,n;
  double[] sum= new double[3];
  double[] k= new double[3];
  //double[][] a= new double[3][5];
  
    for(i=0; i&lt;3; i++){
        n=0;
        sum[i]=0.0;
        for(j=0; j&lt;5; j++){
            if(a[i][j]&gt;0.0){
                sum[i] += (a[i][j])*2;
                n++;
            }                
        }
        k[i]=sum[i]/n;
        System.out.println("k[" + i + "] = " + k[i]); 
   }
  }
  
  public static void main(String[] args){
      Test3 print= new Test3();
      print.Scores();
      print.MD();
      print.sumD();
  
   }  
  }
  </code></pre>
  
  <p>Thanks in advance.</p>