public static void main(String [] args){
}
public:因为权限必须是最大的。
static :不需要对象的,直接用主函数所属类名调用即可。
void:主函数没有具体的返回值。
main:函数名,不是关键字,只是jvm识别的固定的名字。
String [] args:这是主函数的参数列表,是一个数组类型的参数,而且元素都是字符串类型。
public static void main(String [] args){
System.out.println(args);
}
args是长度为0的字符串数组,相当于 String [] args =new String [0];
输出结果为[Ljava.lang.String;@1fb8ee3
[代表是数组
java.lang.String代表字符类型
@1fb8ee3代表内存地址
给主函数传值
java Test helloworld
public static void main(String [] args){
System.out.println(args[0]);
}
控制台就会输出 helloworld