/**
 * An example that illustrates some issues that arise when
 * nested blocks are used with exception handling
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class NestedBlockExample
{
    public static void main(String[] args)
    {
       double         value;
       int            i;


       System.out.println("\n\nThe first way: \n");
//[0
       for (i=0; i < args.length; i++)
       {
          try
          {
             value = Double.parseDouble(args[i]);
             System.out.println(args[i]+" is a number");
          } 
          catch (NumberFormatException nfe)
          {
             System.out.println("Not a number");
          }
       }
//]0
       System.out.println("\n\nThe second way: \n");
//[1
       try 
       {
          for (i=0; i < args.length; i++) 
          {
             value = Double.parseDouble(args[i]);
             System.out.println(args[i]+" is a number");
          }
       } 
       catch (NumberFormatException nfe)
       {
          System.out.println("Not a number");
       }
//]1
    }
}
