Created
October 9, 2021 14:25
-
-
Save nowshad-hasan/0fc5e5b58c92cfe5a3ca29f18e4ef1f9 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
void checkLocalInterface() { | |
interface Runner { | |
void run(); | |
} | |
Runner runner = () -> System.out.println("Running"); | |
runner.run(); | |
} | |
void checkLocalEnum() { | |
enum COLOR {RED, PURPLE, BLUE} | |
System.out.println(Arrays.toString(COLOR.values())); | |
} | |
/* | |
Local enum is implicitly static. So, we can't work with non-static variable in local enum. | |
*/ | |
void checkLocalEnum2() { | |
int val = 2; | |
enum LEVEL { | |
LOW, MID, HIGH; | |
void getValue() { | |
System.out.println(this); | |
// System.out.println(val); // ERROR, non-static variable can't be referenced from static context. | |
} | |
} | |
for (LEVEL level : LEVEL.values()) { | |
level.getValue(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment