ã¡ã³ãå¤æ°å®£è¨æã®åæåï¼ã³ã³ã¹ãã©ã¯ã¿ã«ããåæå
é©å½ã«ããã®ããããªãå¦çãçç£ãã¦ããããããããªããã¨ã«ãªã£ã¦ããã£ãã®ã§ã¡ã¢ã£ã¦ããã
ä¸è¨ã®å®è¡çµæã¯ä»¥ä¸ã®ããã«ãªãã
parent null
ChildInitAtMemberDeclãéã³ã³ãã¤ã«ããã¨ä»¥ä¸ã®ããã«ãªãã
class ChildInitAtMemberDecl extends ParentInitAtMemberDecl { ChildInitAtMemberDecl() { childStr = null; } protected void init() { super.init(); childStr = "child"; } public String getChildStr() { return childStr; } private String childStr; }
è¦ã¦åããéããã¡ã³ãå¤æ°å®£è¨æã«åæå ï¼ ã³ã³ã¹ãã©ã¯ã¿ã§åæåã¨ãªãã
ChildInitAtMemberDeclã®åæåæé ã¯ä»¥ä¸ã®ããã«ãªãã
- Childã®ã³ã³ã¹ãã©ã¯ã¿ã§Parentã®ã³ã³ã¹ãã©ã¯ã¿ãå¼ã¶
- Parentã®ã³ã³ã¹ãã©ã¯ã¿ããChildã§ãªã¼ãã¼ã©ã¤ãããinitãå¼ã°ãã
- super.initã§parentStrã«æååãã»ãã
- Childã®initã«å¦çãæ»ããchildStrã«æååãã»ãã
- Parentã®ã³ã³ã¹ãã©ã¯ã¿ã«å¦çãæ»ã
- Childã®ã³ã³ã¹ãã©ã¯ã¿ã«å¦çãæ»ããchildStrã«nullãã»ãã
ã¾ãã(åè¨äºã«å¼ãç¶ã)æåãããããªã³ã¼ãã£ã³ã°ãããªã¨ãã話â¦â¦ã