Answers for "java enum value"

3

enum java

private enum VarState {
	INIT, 
	TRUE, 
  	FALSE,
	UNSATISFIABLE 
}
Posted by: Guest on January-17-2021
0

java add constructor to enum

package cakes;

public class EnumDemo {

	public enum Food {
		HAMBURGER(7), FRIES(2), HOTDOG(3), ARTICHOKE(4);

		Food(int price) {
			this.price = price;
		}

		private final int price;

		public int getPrice() {
			return price;
		}
	}

	public static void main(String[] args) {
		for (Food f : Food.values()) {
			System.out.print("Food: " + f + ", ");

			if (f.getPrice() >= 4) {
				System.out.print("Expensive, ");
			} else {
				System.out.print("Affordable, ");
			}

			switch (f) {
			case HAMBURGER:
				System.out.println("Tasty");
				continue;
			case ARTICHOKE:
				System.out.println("Delicious");
				continue;
			default:
				System.out.println("OK");
			}
		}

	}

}
Posted by: Guest on October-03-2020
-1

Java Enum

1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
Posted by: Guest on October-11-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language