Created
June 3, 2013 13:30
-
-
Save ozgun/5698142 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 class DowncastingExample { | |
| public static void main(String args[]) { | |
| Object[] o = new Object[2]; | |
| o[0] = new Hayvan(); // upcasting | |
| o[1] = new Kedi(); // upcasting | |
| Hayvan a2 = (Hayvan) o[0]; // downcasting | |
| Kedi a3 = (Kedi) o[1]; // downcasting | |
| } | |
| } | |
| class Hayvan { | |
| public static int x = 1; | |
| } | |
| class Kedi extends Hayvan { | |
| public static int x = 1; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment