class demo {
private int length;
private static int breadth;
void output(){
length=5;
System.out.println(length);
}
static void staticOutput(){
breadth=10;
System.out.println(breadth);
}
public static void main(String args[]){
demo d1=new demo();
d1.output(); // Note here output() function is not static so here
// we need to create object
staticOutput(); // Note here staticOutput() function is static so here
// we needn't to create object Similar is the case with main
/* Although:
demo.staticOutput(); Works fine
d1.staticOutput(); Works fine */
}
}
ClassName是JVM的command-line argument,它告诉JVM要执行哪个类。在ClassName之后,还可以指定list of Strings(用空格分隔)作为JVM将传递给应用程序的命令行参数。-这样的参数可以用来指定运行应用程序的选项(例如文件名)-这就是为什么在主文件中有一个名为String[] args的参数