title: keep program running after throwing exception in java
body: <p>i've wrote a code which i want to keep running after throwing an exception.
  here's my code:</p>
  
  <pre><code>    public class SquareEquationException extends Exception{
       public SquareEquationException(){
          super("roots are not real numbers");
      }
       public static void SquareEquation() throws SquareEquationException{
           double a,b,c,sqr;
           int flag;
           Scanner in = new Scanner(System.in);
           System.out.println("enter ax^2:");
           a=in.nextDouble();
           System.out.println("enter bx:");
           b=in.nextDouble();
           System.out.println("enter c:");
           c=in.nextDouble();
           sqr=((b*b)-(4*a*c));
           if(sqr&lt;0)
               throw new SquareEquationException();
           else{
            sqr=Math.sqrt(sqr);
            double x1=(-b+sqr)/(2*a);
            double x2 = (-b-sqr)/(2*a);
            if(x1==x2)
                   System.out.println("root is:" + x1);
            else
                   System.out.println("x1 is:"+x1 +"\n"+ "x2 is:"+x2 );
  
           }
           System.out.println("enter 1 to continue or any key to exit");
           flag = in.nextInt();
           while(flag==1){
               System.out.println("enter ax^2:");
           a=in.nextDouble();
           System.out.println("enter bx:");
           b=in.nextDouble();
           System.out.println("enter c:");
           c=in.nextDouble();
           sqr=((b*b)-(4*a*c));
           if(sqr&lt;0){
               throw new SquareEquationException();
           }
           else{
            sqr=Math.sqrt(sqr);
            double x1=(-b+sqr)/(2*a);
            double x2 = (-b-sqr)/(2*a);
            if(x1==x2)
                   System.out.println("root is:" + x1);
            else
                   System.out.println("x1 is:"+x1 +"\n"+ "x2 is:"+x2 );
           }
           System.out.println("enter 1 to continue or any key to exit");
           flag=in.nextInt();
       }
       }
       public static void main(String[] args) throws SquareEquationException{
           SquareEquation();
       }
  }
  </code></pre>
  
  <p>how can i keep the menu/program running after throwing an exception?
  menu's work: if 1 inserted by user program keeps on running, else program exits.</p>
  
  <p>EDIT:
  <a href="http://i.stack.imgur.com/7iZcU.png" rel="nofollow">i want to get the message in red and keep it running, so the menu will show right after/before and offer to continue</a></p>