Answer the question
In order to leave comments, you need to log in
How to set fields for Enum?
Help, please, I'm creating a class Fruit, which has fields - fruit type enum and weight. The type of fruit must have a field - a fixed price per kg. How to create a field inside an enum?
public enum Fruit {
APPLE,
ORANGE,
BANANA,
PEAR;
public int getEight() {
return eight;
}
public void setEight(int eight) {
this.eight = eight;
}
private int eight;
Fruit(int eight) {
this.eight = eight;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question