Created
March 3, 2019 23:27
-
-
Save nikhilsinha/930a4288c4306eda346622971f0e5dae to your computer and use it in GitHub Desktop.
Java 8 enum to int example
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
enum DaysOfWeek | |
{ | |
Monday (5), | |
Tuesday (8); | |
private final int integralValue; | |
DaysOfWeek(int dayOfWeek){ | |
integralValue = dayOfWeek; | |
} | |
public int GetIntDayOfWeek() | |
{ | |
return integralValue; | |
} | |
} | |
public class EnumToIntExample{ | |
public static void main(String []args){ | |
System.out.println("Hello World"); | |
System.out.println(DaysOfWeek.Tuesday.GetIntDayOfWeek()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment