Created
July 29, 2021 02:31
-
-
Save zapkub/352d6a8f07d041828daa62f2151c82e2 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 Class1 { | |
int i = 0; | |
} | |
class Class2 extends Class1 { | |
} | |
void main() { | |
Class2 c2 = new Class2(); | |
Class1 c1 = c2; // Class1 is inherited by Class2. so c1 as Class1 can be a subsitiution of c2 | |
for (int i = 0; i < 5; i++) { | |
print('hello ${c1.i++}'); | |
} | |
print('c2 value ${c2.i}'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment