class TestException

    static int x=1;
public static void main(String args[])
{
new TestException().fun();
}
void fun()
{
try 
{
if(x==0)
throw new YException("yy"); 
else if(x==1)
throw new XException("xx");
}
catch(YException e)
{
System.out.println();
}
catch(XException e)
{
System.out.println();
}
}
}

解决方案 »

  1.   

    x=1
    跳到 catch(XException e)  去执行

    System.out.println(); 

      

  2.   

    你的YException和XException这2个在哪里啊!
      

  3.   

    小弟刚自学java 能有更好的方法吗 请给个小例子
      

  4.   

    This topic might help you:
    http://blog.csdn.net/justinavril/archive/2008/08/03/2761119.aspx
      

  5.   


    Maybe he defines them, which extends class Exception.
      

  6.   

    尽量避免用try catch来实现跳转,好像是要花费额外的开销还是怎么的.