java:enum

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
java:enum [2016/02/27 07:54]
gthanos
java:enum [2016/03/03 08:35]
doufexi added example that shows use of .name()
Line 77: Line 77:
 </​code>​ </​code>​
  
 +Για να εκτυπώσετε την τιμή ενός enum ως αλφαριθμητικό μπορείτε να χρησιμοποιήσετε τη μέθοδο //name//:
 +<code java>
 +enum Level { HIGH, MEDIUM, LOW };
 +
 +public class LevelUsage {
 +  public static void main(String []args) {
 +    Level level = Level.HIGH;
 +    System.out.println("​Current level is " + level.name());​
 +  }
 +}
 +</​code>​
 /* /*
 ===== Πεδία και μέθοδοι σε Enum ===== ===== Πεδία και μέθοδοι σε Enum =====
java/enum.txt · Last modified: 2016/03/04 15:10 by doufexi