Source Code : Use an enum constructor, instance variable, and method.
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Use an enum constructor, instance variable, and method.

enum Apple {
A(10), B(9), C(12), D(15), E(8);
private int price; // price of each apple
// Constructor
Apple(int p) {
price = p;
}
int getPrice() {
return price;
}
}
public class EnumDemo3 {
public static void main(String args[]) {
Apple ap;
// Display price of Winsap.
System.out.println(Apple.A.getPrice());
// Display all apples and prices.
System.out.println("All apple prices:");
for (Apple a : Apple.values())
System.out.println(a + " costs " + a.getPrice() + " cents.");
}
}
Thank with us