0
我使用generateTypeScript-gradle插件生成了此類字體。獲取某種字符串類型的所有類型列表
export type FoodUnit = "AS_NEEDED" | "G" | "KG" | "ML" | "L" | "JAR" | "CAN" | "PIECE" | "BUNCH" | "HANDFUL" | "STALK" | "SLICE" | "TABLESPOON" | "TEASPOON" | "DROP" | "CUP" | "TWIG";
現在我想列出一個類中所有可能的單元。
units:FoodUnit[] = ["AS_NEEDED", "G", "KG" .....
有沒有一種方法,而不是寫
units:FoodUnit[] = FoodUnit.values()
喜歡我這一點在Java?