title: Why can't we implement a method inside the main method in Java?
body: <p>Why doesn't this work?</p>
  
  <pre><code>public class AddArray
  {
      public static void main(String[] args) 
      {
  
          int[] x = {1,2,3};
          int[] y = {1,2,3};
  
          dd(x,y);
  
          public static void add(int[]a, int[]b)
          {
              int[] sum = new int[a.length];
              for (int i=0; i&lt;a.length; i++)
                  sum[i] = a[i] + b[i];
              for (int i=0; i&lt;a.length; i++)
                  System.out.println(sum[i]);
          }
      }
  }
  </code></pre>