JAVA编程思想 中一个求素数的习题
小淫侠 2016-11-01 08:06:48 package exercise.four;
import static net.mindview.util.Print.*;
public class Exercise004
{
public static void main(String[] args) {
int max = 100;
// Get the max value from the command line,
// if the argument has been provided:
if(args.length != 0)
max = Integer.parseInt(args[0]);
for(int i = 1; i < max; i++) {
boolean prime = true;
for(int j = 2; j < i; j++)
if(i % j == 0)
prime = false;
if(prime)
System.out.print(i + " ");
}
}
}
请问代码中 :
if(args.length != 0)
max = Integer.parseInt(args[0]);
的用处是什么? 麻烦详细说明下 谢谢