Skip to content

Instantly share code, notes, and snippets.

@nikhilsinha
Created March 3, 2019 23:27
Show Gist options
  • Save nikhilsinha/930a4288c4306eda346622971f0e5dae to your computer and use it in GitHub Desktop.
Save nikhilsinha/930a4288c4306eda346622971f0e5dae to your computer and use it in GitHub Desktop.
Java 8 enum to int example
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