阅读以下程序,写出输出结果。
class LargeCup {
LargeCup(int marker) {
System.out.println("LargeCup(" + marker + ")");
}
void f1(int marker) {
System.out.println("f1(" + marker + ")");
}
}
class Shelf {
static LargeCup cup1 = new LargeCup(1);
Shelf() {
System.out.println("Shelf()");
cup2.f1(1);
}
void f2(int marker) {
System.out.println("f2(" + marker + ")");
}
static LargeCup cup2 = new LargeCup(2);
}
class Cupshelf {
static LargeCup cup3 = new LargeCup(3);
static LargeCup cup4 = new LargeCup(4);
Cupshelf() {
System.out.println("Cupshelf()");
cup4.f1(2);
}
void f3(int marker) {
System.out.println("f3(" + marker + ")");
}
static LargeCup cup5 = new LargeCup(5);
}
public class Initialization {
static Shelf shelf = new Shelf();
static Cupshelf cupshelf = new Cupshelf();
public static void main(String[] args) {
System.out.println("Creating new Cupshelf1() in main");
new Cupshelf();
System.out.println("Creating new Cupshelf2() in main");
new Cupshelf();
shelf.f2(1);
cupshelf.f3(1);
new Initialization();
}
}
