Java应用程序的命令行参数
public class ValueOfDemo {public static void main(String[] args) {
//this program requires two arguments on the command line
if (args.length == 2) {
//convert strings to numbers
float a = (Float.valueOf(args[0]) ).floatValue();
float b = (Float.valueOf(args[1]) ).floatValue();
//do some arithmetic
System.out.println("a + b = " + (a + b) );
System.out.println("a - b = " + (a - b) );
System.out.println("a * b = " + (a * b) );
System.out.println("a / b = " + (a / b) );
System.out.println("a % b = " + (a % b) );
} else {
System.out.println("This program requires two command-line arguments.");
}
}
}问题:如何给命令行参数args[0]和args[1]赋值?
----------------解决方案--------------------------------------------------------
eclisps里能,别的不知道了。
----------------解决方案--------------------------------------------------------
运行使用类似下面的命令:
java ValueOfDemo 96 45
----------------解决方案--------------------------------------------------------
回复 3楼 freish
这个语句要放在哪个位置? ----------------解决方案--------------------------------------------------------
回复 3楼 freish
哦,我明白了,我去试试 ----------------解决方案--------------------------------------------------------
回复 3楼 freish
谢啦 ----------------解决方案--------------------------------------------------------