title: Writing a function inside the main method - Java
body: <p>Can you write a method inside the main method? For example I found this code:</p>
  
  <pre><code>public class TestMax {
      public static void main(String[] args) {
      int i = 5;
      int j = 2;
      int k = max(i, j);
      System.out.println("The maximum between is " + k);
  }
  
   public static int max(int num1, int num2) {
      int result;
      if (num1 &gt; num2)
         result = num1;
      else
         result = num2;
  
      return result; 
    }
  }
  </code></pre>
  
  <p>Can the method max be coded inside the main method?</p>