Created
November 13, 2017 10:59
-
-
Save zz22394/1e5a097253db10f606dbbed8075c00f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class AbstractClass | |
{ | |
public abstract void method1(); | |
public abstract void method2(); | |
public void method3() { | |
// do Something | |
} | |
public void templateMethod() { | |
// 実装はSubClussに任せる | |
method1(); | |
method2(); | |
// 既に実装した | |
method3(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ConcreteClassA extends AbstractClass | |
{ | |
public void method1() { | |
System.out.println("method 1 in ConcreteClassA"); | |
} | |
public void method2() { | |
System.out.println("method 2 in ConcreteClassA"); | |
// 下記のように、method3をコールすることは避けるべき | |
//method3(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment