理解Java主函数中的"String[] args"
public class Understand_String_args
{
public static void main(String[] args)
{
System.out.printf("args[0] = %s\n", args[0]);
System.out.printf("args[1] = %s\n", args[1]);
System.out.printf("args[2] = %s\n", args[2]);
}
}
输出结果:
java Understand_String_args Hello world myfriend!
args[0] = Hello
args[1] = world
args[2] = myfriend!