…………if(xxx) {
    …………
}

解决方案 »

  1.   

    if 条件不满足
       return;
    ....
      

  2.   

    用break;或者continue;
    两者的区别就看下面的例子吧
    //break1.java
    public class break1 {
    public static void main(String args[]){

       for (int i=0;i<5;i++){
       if (i==3) break;
               System.out.println("the number is"+i);
               }
               for (int i=0;i<5;i++){
       if (i==3) continue;
               System.out.println("the number is"+i);
       }    }
    }结果:
    the number is0
    the number is1
    the number is2
    the number is0
    the number is1
    the number is2
    the number is4
      

  3.   

    if(condition){
    ....
    }
    一旦条件不满足就不执行,换句话说就是一旦条件满足就执行,太简单了吧
      

  4.   

    我的意思是
    class hello{
    if(condition){
    ...
    }
    run(){}
    ...}
    condition后面的语句中包括一条语句使得不再运行hello这个类。
      

  5.   

    System.exit(1)
    试试这个如何
      

  6.   

    方法里面
    1、返回为void的用return类就用System.exit(int)。
      

  7.   

    方法里面
    1、返回为void的
       用return;
    2、返回不是void的
       用return xx;
    类就用System.exit(int)。