在类Myclass
中,类Help
作为对象加载,然后在Help
类本身中再次加载。类不是Help
加载了两次吗?这样做的原因是什么?
例如:
public class Myclass {
int i;
Object help;
public Myclass() {
help = new Help(); /// help class loaded
}
private Object doSomething(int h) {
Help.getHelp(h);
}
}
帮助类:
public class Help(){
Object returnhelp;
int h;
public Help() {
int h=3;
}
public Help getHelp(int y) {
return new Help(y); ///// Help class loaded again ????
}
private add(int y) {
h=+y;
return h;
}
}