title: Use an array in multiple methods
body: <p>I am creating a program with <strong>2 methods</strong>.</p>
  
  <p>In the first method I create an <strong>array</strong>, and in the second method I have to <strong>display</strong> that array <strong>like a table</strong>.</p>
  
  <p>So my question is, how do I create an array in the first method and pass it to the second method for displaying?</p>
  
  <pre class="lang-java prettyprint-override"><code>public class test {
  
      public static void main(String[] args) {
          first();
          second();
      }
      public static void first () {
          int N= (int)(Math.random()*5)+1;
          int M= (int)(Math.random()*5)+1;
          int v [][] = new int [N][M];
          for(int i=0; i &lt; v.length; i++) {
              for(int j=0; j &lt; v[0].length; j++) {
                  v [i][j]= (int)(Math.random()*5);
              }
          }
      }
      public static void second () {
          for(int i=0; i &lt; v.length; i++) { 
              for(int j=0; j &lt; v[0].length; j++)
                  System.out.print(v [i][j] + " ");
              System.out.println("");
          }
      }
  }
  </code></pre>
  
  <p>how can I pass the array "v" in the second method?</p>