Created
January 19, 2022 01:35
-
-
Save nhomble/7e56c87d40110c5a8caa225a2c3dfa0a to your computer and use it in GitHub Desktop.
first look at Java enumerations
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
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