【发布时间】:2021-08-19 20:14:53
【问题描述】:
我创建了一个枚举
public enum Fruit {
mango , banana , apple , guava;
}
我有一个函数,我想将枚举作为参数传递并使用该参数。 功能是这样的
getFruits(Fruit.apple) // calling function
public void getFruit( **What to write here to use that Fruit enum**) {
double sweetValue = sweetValueOfFruit( **how can i pass Fruit.apple here**)
}
假设 sweetValue 函数在某处定义。
请帮我编写代码(适用于** ** 之间的所有人)。 谢谢,社区:)
【问题讨论】:
标签: java methods encoding enums syntax