第36題 Given: public class Doubler{ public static int doubleMe(Holder h){ return h.getAmount() * 2; } } and: public class Holder { int amount = 10; public void doubleAmount(){amount = Doubler.doubleMe(this);} public in getAmount(){return amount;} //more code here } Place the code framgmets in position to reduce the coupling between Doubler and Holder. public class Doubler{ public static int doubleMe( Place here h){ return Place here * 2; } } public class Holder { int amount = 10; public void doubleAmount(){amount = Doubler.doubleMe( Place here );} SCJP 6.0 認證教戰手冊 黃彬華著 碁峰出版 19 public in getAmount(){return amount;} //more code here } Code Fragments void Holder int Doubler h.getAmount() h this amount
詳解 (共 4 筆)
詳解
22222222222222222222222222222222222222222222222222
詳解
NICE
詳解
幹
詳解
Given: public class Doubler{ public static int doubleMe(Holder h){ return h.getAmount() * 2; } } and: public class Holder { int amount = 10; public void doubleAmount(){ amount = Doubler.doubleMe(this); } public int getAmount(){ return amount; } //more code here } ---------------------------------------------------------------------------------------------------- Place the code framgmets in position to reduce the coupling between Doubler and Holder. public class Doubler{ public static int doubleMe( Holder h){ return h.getAmount() * 2; } } public class Holder { int amount = 10; public void doubleAmount(){ amount = Doubler.doubleMe(this); } public int getAmount(){ return amount; } //more code here }