java:enum
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
java:enum [2018/02/09 13:31] – gthanos | java:enum [2022/02/24 12:44] (current) – gthanos | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Enumerations ====== | ====== Enumerations ====== | ||
- | Τα // | + | Τα // |
Η πιο απλή δήλωση ενός enumerated τύπου είναι η παρακάτω. | Η πιο απλή δήλωση ενός enumerated τύπου είναι η παρακάτω. | ||
Line 8: | Line 8: | ||
enum Level { HIGH, MEDIUM, LOW }; | enum Level { HIGH, MEDIUM, LOW }; | ||
- | public | + | class LevelUsage { |
- | | + | static void main(String []args) { |
Level level = Level.HIGH; | Level level = Level.HIGH; | ||
System.out.println(" | System.out.println(" | ||
Line 27: | Line 27: | ||
enum Level { HIGH, MEDIUM, LOW }; | enum Level { HIGH, MEDIUM, LOW }; | ||
- | public | + | class LevelUsage { |
- | | + | static void main(String []args) { |
Level level = Level.HIGH; | Level level = Level.HIGH; | ||
if(level == Level.HIGH) | if(level == Level.HIGH) | ||
Line 45: | Line 45: | ||
enum Level { HIGH, MEDIUM, LOW }; | enum Level { HIGH, MEDIUM, LOW }; | ||
- | public | + | class LevelUsage { |
- | | + | static void main(String []args) { |
Level level = Level.HIGH; | Level level = Level.HIGH; | ||
switch(level) { | switch(level) { | ||
Line 68: | Line 68: | ||
enum Level { HIGH, MEDIUM, LOW }; | enum Level { HIGH, MEDIUM, LOW }; | ||
- | public | + | class LevelUsage { |
- | | + | static void main(String []args) { |
Level level = Level.HIGH; | Level level = Level.HIGH; | ||
for(Level l: Level.values()) | for(Level l: Level.values()) | ||
Line 81: | Line 81: | ||
enum Level { HIGH, MEDIUM, LOW }; | enum Level { HIGH, MEDIUM, LOW }; | ||
- | public | + | class LevelUsage { |
- | | + | static void main(String []args) { |
Level level = Level.HIGH; | Level level = Level.HIGH; | ||
System.out.println(" | System.out.println(" | ||
Line 90: | Line 90: | ||
- | |Προηγούμενο: | + | |Προηγούμενο: |
java/enum.1518183066.txt.gz · Last modified: 2018/02/09 13:31 by gthanos