m******u 发帖数: 12400 | 1 class HelloMyWorld {
HelloMyWorld(){
System.out.println("Hello my world!");
}
}
public class HelloWorld {
private String person;
HelloWorld (String person){
this.person = person;
System.out.println(this.person+ new HelloMyWorld());
}
public static void main(String [] args){
new HelloWorld(args[0]);
}
} |
z*********e 发帖数: 10149 | 2 call stack?
Step by step debug can help you understand how it runs |
A******e 发帖数: 6 | 3 Java class initialize sequence is like this: static variables->instance
variables->constructors. |
m******u 发帖数: 12400 | 4 class HelloMyWorld {
HelloMyWorld(){
System.out.println("Hello my world!");
}
}
public class HelloWorld {
private String person;
HelloWorld (String person){
this.person = person;
System.out.println(this.person+ new HelloMyWorld());
}
public static void main(String [] args){
new HelloWorld(args[0]);
}
} |
z*********e 发帖数: 10149 | 5 call stack?
Step by step debug can help you understand how it runs |
A******e 发帖数: 6 | 6 Java class initialize sequence is like this: static variables->instance
variables->constructors. |
x*****2 发帖数: 117 | 7 当执行System.out.println(this.person …… 时需要初始化
HelloMyWorld类,而该类的构造函数中打印输出“Hello my world!”字符串,所以先于
args[0]。
:class HelloMyWorld {
: HelloMyWorld(){ |