Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum Apple {
- RED("drink"), GREEN("cook");
- private final String color;
- Apple(String colorNew) {
- this.color = colorNew;
- }
- String getColor() {
- return color;
- }
- }
- public class EnumTest3 {
- public static void main(String[] args) {
- for (Apple a : Apple.values()) {
- //inside println we can type "a.name()" to get name
- //or simply type "a" as follows:
- System.out.println(a +" apples are used to "+ a.getColor());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement