「Java」「enum」 Chapter4 Question16
Given:
Answer:
enum列舉中,建構子必須是private。
所以修改為: public TWMoney(int i)
要實作列舉中的欄位,不可用new
修改為: TWMoney curr = TWMoney.Hundred;
enum TWMoney{ Ten(10),Hundred(100),Thousand(1000); private int worth; public TWMoney(int i) { this.worth = i; } public int getWorth() { return worth; } } public class Test5 { public static void main(String[] args) { TWMoney curr = new TWMoney.Hundred; System.out.println(curr.getWorth()); } }
Answer:
enum列舉中,建構子必須是private。
所以修改為: public TWMoney(int i)
要實作列舉中的欄位,不可用new
修改為: TWMoney curr = TWMoney.Hundred;
Stainless Steel PS4 Controller
回覆刪除The Original Sega Genesis ford escape titanium for sale Controller with 8-Button Arcade Pad. The Original Sega Genesis Controller titanium prices with 8-Button Arcade Pad. mens black titanium wedding bands 8-Button toaks titanium Controller for the titanium mens wedding bands Sega Genesis Mini.