Skip to content

Instantly share code, notes, and snippets.

@nhomble
Created January 19, 2022 01:35
Show Gist options
  • Save nhomble/7e56c87d40110c5a8caa225a2c3dfa0a to your computer and use it in GitHub Desktop.
Save nhomble/7e56c87d40110c5a8caa225a2c3dfa0a to your computer and use it in GitHub Desktop.
first look at Java enumerations
public class EnumExample {
enum Seasons {
WINTER, SPRING, SUMMER, FALL;
}
public static boolean needJacket(Seasons s){
return s == Seasons.WINTER || s == Seasons.FALL;
}
public static void main(String[] args) {
System.out.println("It is: " + Seasons.WINTER.name());
if(needJacket(Seasons.WINTER)){
System.out.println("I should wear a jacket");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment