0

大家好!我编写了这个程序来读取命令行参数。

public class UseArgument {
public static void main(String args[])
{
    System.out.print("hi, ");
    System.out.print(args[0]);
    System.out.println(" How are you?");
}
}

我尝试通过命令行发送以下参数:

java UseArgument @!&^%

它抛出如下错误。输出:

hi, @! How are you?

''%'' 不是内部或外部命令、可运行程序或批处理文件。

java UseArgument @!^%

任何人都可以解释这种行为吗?这与正则表达式有关吗?

谢谢。西瓦基兰 B

4

1 回答 1

6

Some of the special characters you are using have a meaning to the shell from which you are launching your program. By putting the characters in quotes, you are instructing the shell not to process these characters according to their special meaning.

于 2012-09-07T06:07:00.747 回答