title: Try-catch placement in a recursive Java function call
body: <p>Trying to figure out the best place to put a try catch statement when a recursive call is placed. The factorial computation is done with long datatype. Expecting an exception to be thrown when the factorial becomes too huge to fit into a long variable.</p>
  
  <p>However the code is showing factorial = 0 whenever it's too large. No exception is being thrown. So is there a problem with the try-catch placement or does putting over-large numbers throw no exception?</p>
  
  <pre><code>class Fact
  {
      static long fact(long n)
      {
         if(n==1)
             return 1;
          return n*fact(n-1);
      }
  
  public static void main(String args[])
  {
      try{
          long f = fact(555);
          System.out.println("Factorial = "+f);
      }
      catch(Exception e){
              System.out.println("Exception = "+e);
      }
  }
  }
  </code></pre>