title: In Java, how to assign the variable number=Integer.parseInt(args[0]) a value if no argument is passed?
body: <p>I wrote this simple program, that takes a command line argument, converts it into int type, and prints integers starting from that number till infinity on console.</p>
  
  <p>If i don't pass any argument, then my exception message is printed.</p>
  
  <pre><code>public class Infinity
  {
      public static void main(String args[])
      {
  
          try
          {
              n=Integer.parseInt(args[0]);
  
              while(true)
              {
                  System.out.println(n);
                  n++;
              }
          }
  
          catch(Exception ex)
          {
              System.out.println("A number was not entered.");
          }
      }
  }
  </code></pre>
  
  <p>Is there any way that if i don't pass any argument, the program itself assigns a value to 'n'? Like this:</p>
  
  <pre><code>            n=Integer.parseInt(args[0]);
              if(args[0]==NULL)
              {
                  n=0;
              }
  </code></pre>