⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 orderofinitialization.java

📁 Java例程
💻 JAVA
字号:
//: OrderOfInitialization.java
// Demonstrates initialization order.
// When the constructor is called, to create a
// Tag object, you'll see a message:
class Tag {
	Tag(int marker) {
		System.out.println("Tag(" + marker + ")");
	}
}

class Card {
	Tag t1 = new Tag(1); // Before constructor
	
	Card() {
		// Indicate we're in the constructor:
		System.out.println("Card()");
		t3 = new Tag(33); // Re-initialize t3
	}
	
	Tag t2 = new Tag(2); // After constructor
	
	void f() {
		System.out.println("f()");
	}
	
	Tag t3 = new Tag(3); // At end
}

public class OrderOfInitialization {
	public static void main(String[] args) {
		Card t = new Card();
		t.f(); // Shows that construction is done
	}
} ///:~

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -