下面的代码是我从一本书中看到的,中间的usage不知道有何用处,请各位指点一下,谢谢!该类主要用于检查Math.random()的输出范围是否包含了0.0或1.0public class RandomBoundsDemo {

static void usage(){//这个函数的作用是什么???
System.out.println("Usage:\n\t"+
"RandomBounds lower\n\t RandomBounds upper");
System.exit(1);
}

public static void main(String[] args) {
if(args.length!=1)usage();

if(args[0].equals("lower")){
while(Math.random()!=0.0);
System.out.println("produced 0.0!");
}
else if(args[0].equals("upper")){
while(Math.random()!=1.0);
System.out.println("produced 1.0");
}
else 
usage();
}
}

解决方案 »

  1.   

    usage不是main里面调用了吗
    就是如果运行的时候没带参数就提示你
      

  2.   

    System.exit(1);
    楼主应该是这个函数看不懂吧,这个函数作用终止当前运行的 Java 虚拟机,该参数用作状态码,按照约定,一个非零状态码指示非正常终止。
      

  3.   

    System.exit(1);
    楼主应该是这个函数看不懂吧,这个函数作用终止当前运行的 Java 虚拟机,该参数用作状态码,按照约定,一个非零状态码指示非正常终止。
    =================================================================================
    非正常终止与正常终止有什么区别?