title: Command line argument in Java is giving an error
body: <p>I am trying to write a very simple program to receive input from the user and print it out again on the screen. But I'm getting an error.</p>
  
  <p>My code:-</p>
  
  <pre><code>import java.util.*;
  
  class res_cmd {
      public static void main(String args[]){
          int first;
          System.out.println("Enter a number");
          first = Integer.parseInt(args[0]);
          System.out.println("The result is"+first);
      }
  }
  </code></pre>
  
  <p>The error I'm getting:-</p>
  
  <p>C:\Users\hp\Desktop>java res_cmd</p>
  
  <pre><code>Enter a number
  Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
          at res_cmd.main(res_cmd.java:7)
  </code></pre>
  
  <p>I am not sure why I'm getting this error. Scanner class and Buffer method are working but command line is not. Please help.</p>