Created
July 29, 2021 02:28
-
-
Save zapkub/899e4d7dfa937cf972b35b48f8053567 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 { | |
static Class1 instance = new Class1(); | |
int i = 0; | |
} | |
class Class2 { | |
void set i(int val) { | |
Class1.instance.i = val; | |
} | |
int get i { | |
return Class1.instance.i; | |
} | |
} | |
void main() { | |
Class1 c1 = Class1.instance; | |
Class2 c2 = new Class2(); | |
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