Last active
December 23, 2021 18:28
-
-
Save zindmax/3acf2b35c2b6a9b57e1950131587f884 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
class Base { | |
public int x = 0; | |
} | |
class Child extends Base{ | |
public int x = 1; | |
} | |
public class Main | |
{ | |
public static void main(String[] args) { | |
Base base = new Child(); | |
System.out.println(base.x); | |
Child child = (Child) base; | |
System.out.println(child.x); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment