Java – Constructor Chaining 張貼者: Android/ios/flutter app designer. 日期: 2月 11, 2018 取得連結 Facebook X Pinterest 以電子郵件傳送 其他應用程式 Java語言最厲害的就是Constructor. Constructor用得好,寫起程式就像是拿起筆來寫文章得心應手. Constructor Chaining是很重要的. public class Foo { private int x; public Foo() { this(1); } public Foo(int x) { this.x = x; } } 重複的code寫越少, 將來修改時就能改得比較好. 小地方可以看出此人的程式功力. 留言 婊爆俠寫道… 其實就是導引使用這個物件的人去接受並使用「預設值」而不用去煩惱這個物件底下的參數設計
留言
而不用去煩惱這個物件底下的參數設計