-
-
Save takahashi-h5/811858064d6dc55d4663538e1afc0e79 to your computer and use it in GitHub Desktop.
This file contains 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
class Parent { | |
public void angry() { | |
System.out.println("こら"); | |
} | |
} | |
class Child extends Parent{ | |
public void sorry() { | |
System.out.println("ごめん"); | |
} | |
} | |
public class Main { | |
public static void main(String[] args) { | |
Child chi = new Child(); | |
Parent papa = (Parent)chi;// 子クラスから親クラスにはキャストできる | |
papa.angry(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment